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