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