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