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