// editor2
#include<stdio.h>
#include<stdlib.h>
#include<stdio.h>
#include<stdlib.h>
typedef struct node{
    int data;
    struct node *left;
    struct node *right;
}Node;
Node *root=NULL;
Node *create(int val){
Node *newnode=(Node*)malloc(sizeof(Node));
newnode->data = val;
newnode->left = newnode->right=NULL;
return newnode;
Node *insertBST(Node *root,int t){
    if(root == NULL)
    return create(t);
    if(t<root->data){
        root->left=insertBST(root->left,t);
    }
    else
     root->right=insertBST(root->right,t);
     return root;
}
void postorder(Node *root){
    if(root == NULL)
        return;
    postorder(root->left);
    postorder(root->right);
    printf("%d ",root->data);
    }
    int main(){
        int size;
        scanf("%d ",&size);
        if(size<0){
            printf("Invalid input");
            return 0;
        
    }
    Node *root=NULL;
    for(int i=0;i<size;i++){
    int time;
    scanf("%d",&time);
    if(time<5){
        printf("Invalid input");
        return 0;
    }
    root = insertBST(root,time);
    }
    postorder(root);
}