#include<stdio.h>
#include<stdlib.h>
typedef struct TreeNode{
    int data;
    struct TreeNode *left;
    struct TreeNode *right;
}node;

node *root=NULL;
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->left);
        printf("%d ",root->data);
        sortedorder(root->right);
    }
}
int main(){
    int size,val,num,i;
    node *root=NULL;
    scanf("%d",&size);
    if(size<0){
        printf("Invalid input");
        return 0;
    }
    scanf("%d",&val);
    if(val<0){
        printf("Invalid input");
        return 0;
    }
    for(i=0;i<size;i++){
    scanf("%d",&num);
    if(num<0){
        printf("Invalid input");
        return 0;
        root=insertBST(root,num);
    }
    root=insertBST(root,val);
    sortedorder(root);
    return 0;
}