// editor2
// editor2
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.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 insertMiddle(struct Node** head, int val, int n) {
    struct Node* newNode = createNode(val);
    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) {
    struct Node* temp = head;
    while (temp != NULL) {
        printf("%d", temp->data);
        if (temp->next != NULL) printf(" ");
        temp = temp->next;
    }
}
int isNumeric(char* str) {
    for (int i = 0; i < strlen(str); i++) {
        if (!isdigit(str[i])) return 0;
    }
    return 1;
}

int main() {
    int n, val;
    char buffer[10000];

    if (scanf("%d", &n) != 1 || n < 0 || n > 1000) {
        printf("Invalid input");
        return 0;
    }

    struct Node* head = NULL;
    struct Node* tail = NULL;

    for (int i = 0; i < n; i++) {
        if (scanf("%s", buffer) != 1 || !isNumeric(buffer)) {
            printf("Invalid input");
            return 0;
        }
        int num = atoi(buffer);
        struct Node* newNode = createNode(num);

        if (head == NULL) {
            head = tail = newNode;
        } else {
            tail->next = newNode;
            tail = newNode;
        }
    }
    if (scanf("%s", buffer) != 1 || !isNumeric(buffer)) {
        printf("Invalid input");
        return 0;
    }
    val = atoi(buffer);

    insertMiddle(&head, val, n);

    printList(head);

    return 0;
}// editor2
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.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 insertMiddle(struct Node** head, int val, int n) {
    struct Node* newNode = createNode(val);
    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) {
    struct Node* temp = head;
    while (temp != NULL) {
        printf("%d", temp->data);
        if (temp->next != NULL) printf(" ");
        temp = temp->next;
    }
}
int isNumeric(char* str) {
    for (int i = 0; i < strlen(str); i++) {
        if (!isdigit(str[i])) return 0;
    }
    return 1;
}

int main() {
    int n, val;
    char buffer[10000];

    if (scanf("%d", &n) != 1 || n < 0 || n > 1000) {
        printf("Invalid input");
        return 0;
    }

    struct Node* head = NULL;
    struct Node* tail = NULL;

    for (int i = 0; i < n; i++) {
        if (scanf("%s", buffer) != 1 || !isNumeric(buffer)) {
            printf("Invalid input");
            return 0;
        }
        int num = atoi(buffer);
        struct Node* newNode = createNode(num);

        if (head == NULL) {
            head = tail = newNode;
        } else {
            tail->next = newNode;
            tail = newNode;
        }
    }
    if (scanf("%s", buffer) != 1 || !isNumeric(buffer)) {
        printf("Invalid input");
        return 0;
    }
    val = atoi(buffer);

    insertMiddle(&head, val, n);

    printList(head);

    return 0;
}