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