#include<stdio.h>
#include<stdlib.h>
typedef struct node{
    char ch[20];
    struct node*left;
    struct node*right;
}Node;
Node*root=NULL;
Node*create(int fun){
    Node*newNode=(Node*)malloc(sizeof(Node));
    newNode->ch=fun;
    newNode->left=NULL;
    newNode->right=NULL;
    return newNode;
}
void*insert(Node*root,int num){
    if(root==NULL)
    return create(fun);
    if(num<root->ch)
    root->left=insert(root->left,fun);
    else if(num<root->ch)
    root->right=insert(root->right,fun);
    return root;
}
void inorder(Node*root){
    if(root!=NULL){
    inorder(root->left);
    printf("%d ",root->ch);
    inorder(root->right);
    }
}
int main(){
    int i,num,n;
    scanf("%d",&n);
    if(n<0)
    {
        printf("Invalid input");
        return 0;
    }
    for(i=0;i<n;i++){
        scanf("%d",&num);
        root=insert(root,num);
    }
    inorder(root);
    return 0;
    
}