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