#include<stdio.h>
#include<stdlib.h>

typedef struct Tree{
    int data;
    struct Tree *left,*right;
}tree;

tree *root=NULL;
tree *bran;

tree *create(int num){
    bran=(tree*)malloc(sizeof(tree));
    bran->data=num;
    bran->left=NULL;
    bran->right=NULL;
    return bran;
}

tree *insert(tree *root,int num){
    if(root == NULL){
        return create(num);
        
    }
    if(root->data>num){
        root->left=insert(root->left,num);
    }
    else if(root->data<num){
        root->right=insert(root->right,num);
    }
    return root;
}

void inorder(tree *root){
    if(root!=NULL){
        inorder(root->left);
        printf("%d",root->data);
        inorder(root->right);
    }
}

int main(){
    int size;
    int num,ind;
    scanf("%d",&size);
if(size<0){
    printf("Invalid input");
    return 0;
}

for(ind=0;ind<size;ind++){
    scanf("%d",num);
    root=insert(root,num);
}
inorder(root);
return 0;
}