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