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