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