// editor3
#include<stdio.h>
#include<stdlib.h>
typedef struct node{
    int data;
    struct node *left,*right;
}nd;
nd *root=NULL;
nd *create(int num){
    if(root==NULL){
        return;
    }
    nd *newnode=(nd*)malloc(sizeof(nd));
    newnode->data=num;
    newnode->left=newnode=right=NULL;
    return newnode;
}
nd *insertBST(nd *root,int num){
    if(root==NULL){
        return;
    }
    else if(num<root->left)
        root->left=insertBST(root,num);
    else if(num>root->right)
        root->right=insertBST(root,num);
        return root;
}

void *levelorder(nd *root,int data){
    if(root==NULL) return;
    nd *queue[100],*front=*rear=0;
    queue[rear++]=root;
    while(front<rear){
        nd *curr=queue[front++];
        printf("%d",front->data);
        if(curr->left){
            queue[rear++]=curr->left;
        }
        if(curr->right){
            queue[rear++]=curr->right;
        }
       return root;
    }
}
int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        int val;
        if(n<0 || scanf("%d",&val)<0){
            printf("Invalid input");
            return 0;
        }
       root=insertBST(root,num);
    }
    root=insertBST(root,val);
    levelorder(root,data);
    return 0;
}