#include<stdio.h>
#include<stdlib.h>

struct node
{
    int data;
    struct node *l,*r;
};
struct Node* create(int v)
{
    struct Node* node = (struct Node*)malloc(sizeof(struct Node));
    node->data = v;
    node->l = newnode->r = NULL;
    return newnode;
}
struct Node* insert(struct Node* root,int v)
{
    if(root==NULL)
    return create(v);
    if(v<root->data)
    {
        root->l =insert(root->l,v); 
    }
    else
    root->r = insert(root->right,v);
    
    return root;
}
void post(struct Node* root)
{
    if(root == NULL)
    {
        post(root->l);
        post(root->r);
        printf("%d ",root->data);
        
    }
    int main()
    {
        int n,x;
        scanf("%d",&n);
        if(n<=0)
        {
            printf("Invalid input");
            return 0;
        }
        struct Node* root = NULL;
       
        for(int i=0;i<n;i)
        {
            scanf("%d",&x);
            if(x<0)
            {
              printf("Invalid input");
              return 0;  
            }
            root = insert(root,x);
            
        }
        post(root);
        return 0;
    }