#include<stdio.h>
#include<stdlib.h>
struct node{
    int data;
    struct node*left,*right;
}node;
struct node*createNode(int val){
    struct node*newnode= (struct node*)malloc(sizeof(node));
    newnode->data=val;
    newnode->left=newnode->right=NULL;
    return newnode;
}
struct node*insert(node*root,int val){
    if(root==NULL)
    return createNode(val);
    if(val<root->data)
    root->left-insert(root->left,val);
    else
    root->right=insert(root->right,val);
    return root;
}
void inorder (struct node*root){
    if(root!=NULL){
        inorder(root->left);
        printf("%d",root->data);
        inorder(root->right);
    }
}
int main(){
    int N,X;
    if(N<0){
        printf("Invalid input");
        return 0;
    }
    scanf("%d",&X);
    if(X<0){
        pritnf("Invalid input");
        return 0;
    }
    struct node*root=NULL;
    int val;
    for(int i=0;i<N;i++){
        scanf("%d",&val);
        root=insert(root,val);
    }
    root=insert(root,X);
    inorder(root);
    return 0;
}