// editor2
#include<stdio.h>
#include<stdlib.h>
typedef struct node
{
    int data;
    struct node *right,*left;
}node;
node *newnode,*root=NULL;

node* create(int num)
{
    newnode=(node*)malloc(sizeof(node));
    newnode->data=num;
    newnode->right=NULL;
    newnode->left=NULL;
    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 if(num > root->data)
    {
        root->right=insert(root->right,num);
    }
    return root;
}
void post(node* root)
{
    printf("%d ",root->data);
    post(root->left);
    post(root->right);
}
int main()
{
    int size,n,i;
    scanf("%d",&size);
    if(size<=0)
    {
        printf("Invalid input");
        return 0;
    }
    for(i=0;<size;i++)
    {
        scanf("%d",&n);
        root=insert(root,n);
    }
    post(root);
    return 0;
}