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