// editor3
#include<stdio.h>
#include<stdlib.h>
typedef struct Node{
    int data;
    struct Node* left;
    struct Node* right;
}Node;

Node* create(int val){
    Node*newnode = malloc(sizeof(Node));
    newnode->data=val;
    newnode->left=newnode->right=NULL;
    return newnode;
}
void insert(Node** root,int val){
    Node* newnode=malloc(sizeof(Node));
    if(*root == NULL){
        *root=newnode;
        return;
    }
    Node* queue[100];
    int front=0,rear=0;
    queue[rear++]=*root;
    while(front<rear){
        Node* temp = queue[front++];
        if(!temp->left){
            temp->left=newnode;
        }
        else{
            queue[rear++]=temp->left;
        }
        if(!temp->right){
            temp->right=newnode;
            return;
        }
        else{
            queue[rear++]=temp->right;
        }
    }
}
void printlevleorder(Node* root){
    if(!root){
        return;
    }
    Node* queue[100];
    int front=0,rear=0;
    queue[rear++]=root;
    while(front<rear){
        Node* temp = queue[front++];
        printf("%d",temp->data);
        if(temp->left)queue[rear++]=temp->left;
        if(temp->right)queue[rear++]=temp->right;
    }
}
int main(){
    int n,val;
    scanf("%d",&n);
    if(n<0){
        printf("Invalid input");
        return 0;
    }
    Node* root=NULL;
    for(int i=0;i<n;i++){
        int x;
        scanf("%d",&x);
        insert(&root,x);
    }
    scanf("%d",&val);
    insert(&root,val);
    printleveleorder(root);
    return 0;
}