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