#include<stdio.h>
#include<stdlib.h>
struct Node{
    int data;
    struct Node*next;
};
struct Node*createNode(int data){
     struct Node*newNode=(struct Node*)malloc(sizeof(struct Node));
    newNode->data=data;
    newNode->next=NULL
    return newNode;
}
void insertSorted(struct Node**head,int data){
    struct Node*newNode=createNode(data);
    if(*head==NULL || data<(*head)->data){
        newNode->next=*head;
        *head=newNode;
        return;
    }
    struct Node*temp=*head;
    while(temp->next!=NULL&&temp->next->data<data){
        temp=temp->next;
    }
    newNode->next=temp->next;
    temp->next=newNode;
}
void printList(struct Node*head){
    while(head!=NULL){
        printf("%d",head->data);
        if(head->next!=NULL)printf(" ");
        head=head->next;
    }
    printf("\n");
}
int main(){
    int N,X;
    if(scanf("%d",&N)!=1 || N<=0){
        printf("Invalid input\n");
        return 0;
    }
    if(scanf("%d",&X)!=1){
        printf("Invalid input\n");
        return 0;
    }
    struct Node*head=NULL;
    for(int i=0;i<N;i++){
        int num;
        if(scanf("%d",&num)!=1){
            printf("Invalid input\n");
            return 0;
        }
        insertSorted(&head,num);
    }
    insertSorted(&head,X);
    printList(head);
    return 0;
    }
    
}