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