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