// editor1
#include<stdio.h>
#include<stdlib.h>
typedef struct node{
    int data;
    struct node *left,*right;
}nd;
nd *root=NULL;
nd *create(int num){
    nd *newnode=(nd*)malloc(sizeof(nd));
    newnode->data=num;
    newnode->left=newnode->right=NULL;
    return newnode;
}
nd *insertBST(nd *root,int num){
    if(root==NULL)
        return create(num);
    if(num<root->data)
        root->left=insertBST(root->left,num);
    else if(num>root->data)
        root->right=insertBST(root->right,num);
    return root;
}
void post(nd *root){
    if(root==NULL)
        return;
    post(root->left);
    post(root->right);
    printf("%d ",root->data);
}
int main(){
    int N,num;
    nd *root=NULL;
    scanf("%d",&N);
    for(int i=0;i<N;i++){
        scanf("%d",&num);
        root=insertBST(num);
    }
    post(root);
    return 0;
}