// editor2
#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(root->data<num)
    root->left=insertbst(root->left,num);
    else
    root->right=insertbst(root->right,num);
    return root;
}
void sortorder(node *root){
    if(root!=NULL){
        sortorder(root->left);
        printf("%d ",root->data);
        sortorder(root->right);
    }
}
int main(){
    int size,val,num,i;
    scanf("%d",&size);
    scanf("%d",&val);
    for(i=0;i<size;i++){
        scanf("%d",&num);
        root=insertbst(root,num);
}
insertbst(root,val);
sortedorder(root);
return 0;
}