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