// editor2
#include<stdio.h>
#include<stdlib.h>
typedef struct node{
    int data;
    struct node *l,*r;
    
};
struct node* ins(struct node* t,int x){
    if(!t){
        t=malloc(sizeof(*t));
        t->d=x;t->l=t->r=NULL;
        return t;
        
    }
    if(x<t->d) t->l=ins(t->l,x);
    else t->r=ins(t->r,x);
    return t;
}
void post(struct node*t){
    if(!t)return;
    post(t->l);
    post(t->r);
    printf("%d ",t->d);
    
}
int main(){
    int n,x;
    scanf("%d ",&n);
    if(n<-10||n>35){printf("Invalid Input");return 0;}
    struct node* t=NULL;
    while(n--){
        scanf("%d ",&x);
        if(x<5||x>300){printf("Invalid Input");return 0;}
        t=ins(t,x);
        
    }
    post(t);
}