#include <stdio.h>
#include <stdlib.h>

struct Node {
    int data;
    struct Node* next;
};
struct Node* createNode(int val) {
    struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
    if (!newNode) {
        printf("Memory allocation failed\n");
        exit(1);
    }
    newNode->data = val;
    newNode->next = NULL;
    return newNode;
}
void printList(struct Node* head) {
    struct Node* current = head;
    while (current != NULL) {
        printf("%d", current->data);
        if (current->next != NULL) {
            printf(" ");
        }
        current = current->next;
    }
    printf("\n");
}

int main() {
    int n, val;

    if (scanf("%d", &n) != 1 || n < 0 || n > 1000) {
        printf("Invalid input\n");
        return 0;
    }

    struct Node* head = NULL;
    struct Node* tail = NULL;

    for (int i = 0; i < n; i++) {
        int input;
        if (scanf("%d", &input) != 1) {
            printf("Invalid input\n");
            return 0;
        }

        struct Node* newNode = createNode(input);

        if (head == NULL) {
            head = newNode;
            tail = newNode;
        } else {
            tail->next = newNode;
            tail = newNode;
        }
    }
    if (scanf("%d", &val) != 1) {
        printf("Invalid input\n");
        return 0;
    }

    struct Node* newNode = createNode(val);
    if (head == NULL) {
        head = newNode;
    } else {
        int pos = n / 2;
        struct Node* temp = head;

        for (int i = 0; i < pos - 1; i++) {
            temp = temp->next;
        }

        if (pos == 0) 
        {
            newNode->next = head;
            head = newNode;
        } else {
            newNode->next = temp->next;
            temp->next = newNode; 
        }
    }

    printList(head);
    return 0;
}