#include<stdio.h>
#include<stdlib.h>
typedef struct node{
    int data;
    struct node *left,*right;
}Node;
Node *root=NULL;
Node* create(Node *root,int num){
    Node* newnode=(Node*)malloc(sizeof(Node));
    newnode->data=num;
    newnode->left=NULL;
    newnode->right=NULL;
    return newnode;
}
Node *insert(Node *root){
    if(root==NULL)
    return create(num);
    if(num<root->data)
    return left->data=insert(left->data,num);
    else if(num>root->data)
    return right->data=insert(right->data,num);
    return root;
}
void postOrder(Node *root){
    postOrder(left->data);
    postOrder(right->data);
    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;
}