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