#include<stdio.h>
#include<stdlib.h>
struct Node{
    int data;
    struct Node*left;
    struct Node*right;
};
struct Node*createNode(int value){
    struct Node*newNode=(struct Node*)malloc(sizeof(struct Node));
    newNode->data=value;
    newNode->left=NULL;
    newNode->right=NULL;
    return newNode;
}
struct Node*insert(struct Node*root,int value){
    if(root==NULL)
        return createNode(value);
    
    if(value<root->data)
        root->left=insert(root->left,value)

    else if(value>root->data)
    root->right=insert(root->right,value);

return root;
}
void inOrderTraversal(struct Node*root){
    if(root!=NULL){
        inOrderTraversal(root->left);
        printf("%d",root->data);
        inOrderTraversal(root->right);
    }
}
void freeTree(struct Node* root){
    if(root!=NULL){
        freeTree(root->left);
        freeTree(root->right);
        free(root);
    }
}
int main(){
    int N,X;
    if(scanf("%d",&N)!=1)return 1;
    if(scanf("%d",&X)!=1)return 1;
    
    if(N<0||X<0){
        printf("Invalid input\n");
        return 0;
    }
    struct Node*root=NULL;
    int val;
    for(int i=0;i<N;i++){
        if(scanf("%d",&val)!=1)return 1;
        if(val<0){
            printf("Invalid input\n");
            freeTree(root);
            return 0;
        }
        root=insert(root,val);
    }
    root=insert(root,X);

inOrderTraversal(root);
printf("\n");

freeTree(root);
return 0;
}