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