#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
struct Node
{
    int data;
    struct Node*next;
};
void append(struct Node** head,int val){
    struct Node* newNode=(struct Node*)malloc(sizeof(struct Node));
    newNode->data = val;
    newNode->next = NULL;
    if(*head == NULL){
        *head = newNode;
        return;
    }
    struct Node* temp = *head;
    while (temp->next != NULL)
    temp = temp->next;
    temp->next = newNode;
}
void insertMiddle(struct Node** head, int val,int n){
    struct Node* newNode=(struct Node*)malloc(sizeof(struct Node));
    newNode->data = val;
    newNode->next = NULL;
    if(*head == NULL){
        *head = newNode;
        return;
}
int mid = n/2;
struct Node* temp = *head;
for(int i = 0;i<mid - 1:i++){
    temp = temp->next;
}
newNode->next = temp->next;
temp->next = newNode;
}
void printList(struct Node* head){
    while(*head = NULL){
        printf("%d", head->data);
        head = head->next;
    }
    printf("\n");
}
int isValidNumber(char* str){
    for(int i = 0; str[i];i++){
        if(!isdigit(str[i]) && str[i] != '-')return 0;
    }
    return 1;
}
int main()
{
    int n, val;
    struct Node* head = NULL;
    if (scanf("%d",&n) != 1 || n < 0 || n> 1000){
        printf("Invalid input\n");
        return 0;
    }
    for(int i = 0; i <n; i++){
        int temp;
        if (scanf("%d",& temp) != 1){
            printf("Invalid input\n");
            return 0;
        }
        append(&head, temp);
    }
    if(scanf("%d", &val) != 1){
        printf("Invalid input\n");
        return 0;
    }
    insertMiddle(&head, val, n);
    printlist(head);
    return 0;
}