#include<stdio.h>
#include<stdlib.h>
struct node*left,*right;
};
structnode*createNode(int val){
    structnode*newnode=(structnode*)malloc(sizeof(structnode));
    newnode->data=val;
    newnode->left=newnode->right=NULL;
    return newnode;
}
structnode*insert(structnode*root,int val){
    if(root==NULL)
    return createNode(val);
    if(val<root->data)
    root->left=insert(root->left,val);
    else
    root->right=insert(root->right,val);
    return root;
}
void inorder(structnode*root){
    if(root==NULL)
    return;
    inorder(root->left);
    printf("%d",root->data);
    inorder(root->right);
}
int main(){
    int n,x;
    structnode*root=NULL;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&x);
        if(x<0){
            printf("Invalid input");
            return 0;
        }
        root=insert(root,x);
    }
    inorder(root);
    return 0;
}