// editor2
#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=NULL;
    newnode->right=NULL:
    return newnode;
}
Node* insert(Node *root,int val){
if(root==NULL)
   return create(val);
   if(val < root -> data)
     root->left=insert(root->left,val);
     else
     root->right=insert(root->right,val)
     return root;
}
void inorder(Node *root){
    if(root==NULL)
    return;
    inorder(root->left);
    printf("%d ",root->data);
    inorder(root->right);
}
int main(){
    int n;
    scanf("%d",n);
    int y;
    scanf("%d",&y);
    if(n<0){
        printf("Invalid input");
        return 0;
    }
    if(y<0){
        printf("Invalid input");
        return 0;
    }
    for(int i=0;i<n;i++);
    int x;
    scanf("%d",&x);
    if(x<0){
        printf("Invalid input");
        return 0;
    }
    root=insert(root,x);
}
root=insert(root,y);
inorder(root);
return 0;
}