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