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