#include<stdio.h>
#include<stdlib.h>
typedef strut node{
    int data;
    struct node *left,*right;
}Node;
Node *root=NULL;int num
Node *create(int num){
    Node *newnode=(Node*)malloc(sizeof(Node));
    newnode->data=num;
    newnode->left=NULL;
    newnode->prev=NULL;
    return newnode;
}
Node *insert(Node *root,int num ){
    if(root==NULL)
        return create(num);
    if(num > root->data)
    root->right=insert(root->right,num);
    else if(num < root->data)
    root->left=insert(root->left,num);
    return root;
}
void *postorder(Node *root){
    if(root!=NULL){
        postorder(root->left,num);
        postorder(root->right,num);
        printf("%d",root->data);
    }
}
int main(){
    int itr,num,size;
    scanf("%d",&size);
    for(itr=1;itr<=size;itr++){
        scanf("%d",&num);
        root=insert(root,num);
    }
    postorder(root);
    return 0;
}