#include<stdio.h>
#include<stdlib.h>
struct Node{
    int data;
    structNode*next;
};
structNode*createNode(int data){
    structNode*newNode=(structNode*)malloc(sizeof(structNode));
    newNode->data=data;
    newNode->next=NULL
    return newNode;
}
void insertSorted(structNode**head,int data){
    structNode*newNode=createnode=createNode(data);
    if(*head==NULL || data<(*head)->data){
        newNode->next=*head;
        *head=newNode;
        return;
    }
    structNode*temp=*head;
    while(temp->next!=NULL&&temp->next->data<data){
        temp=temp->next;
    }
    newNode->next=temp->next;
    temp->next=newNode;
}
void printList(structNode*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",&X)!=1){
        printf("Invalid input\n");
        return 0;
    }
    structNode*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;
    }
    
}