#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
struct Node {
    int data;
    struct Node* prev;
    struct Node* next;
};
struct Node* createNode(int value) {
    struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
    newNode->data = value;
    newNode->prev = NULL;
    newNode->next = NULL;
    return newNode;
}
void insertEnd(struct Node** head, int value) {
    struct Node* newNode = createNode(value);
    if (*head == NULL) {
        *head = newNode;
    } else {
        struct Node* temp = *head;
        while (temp->next != NULL) {
            temp = temp->next;
        }
        temp->next = newNode;
        newNode->prev = temp;
    }
}
void displayList(struct Node* head) {
    if (head == NULL) {
        printf("List is empty\n");
        return;
    }
    struct Node* temp = head;
    while (temp != NULL) {
        printf("%d ", temp->data);
        temp = temp->next;
    }
    printf("\n");
}
int isValidInteger(char* str) {
    for (int i = 0; str[i] != '\0'; i++) {
        if (!isdigit(str[i]) && str[i] != '-' && str[i] != '+') {
            return 0;
        }
    }
    return 1;
}
int main() {
    int n;
    char input[50];
    struct Node* head = NULL;
    scanf("%d", &n);

    if (n <= 0) {
        printf("Invalid input\n");
        return 1;
    }
    for (int i = 0; i < n; i++) {
        scanf("%s", input);
        if (!isValidInteger(input)) {
            printf("Invalid input");
            return 1;
        }
        int value = atoi(input);
        insertEnd(&head, value);
    }
    displayList(head);
    return 0;
}