// editor1
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
typedef struct Node{
    int data;
    struct Node* next;
}Node;
Node* createNode(int data){
    Node* newNode = (Node*)malloc(sizeof(Node));
    newNode->data=data;
    newNode->next=NULL;
    return newNode;
}
void insertNode(Node** head, int data){
    Node* newNode=createNode(data);
    if(*head == NULL){
        *head = newNode;
    }
    else{
        Node* temp = *head;
        while(temp->next != NULL){
            temp = temp->next;
        }
    }
    void displayList(Node* head){
        Node* temp=head;
        while(temp != NULL){
            printf("%d",temp->data);
            if(temp->next != NULL){
                printf(" ");
            }
            temp=temp->next;
        }
        printf("\n");
    }
    int isValidInteger(char* str){
        for(int i=0;i<strlen(str);i++){
            if(!isdigit(str[i])){
                return 0;
            }
        }
        return 1;
    }
    int main(){
        int n;
        char input[100];
        scanf("%d",&n);
        if(n<0 || n>10){
            printf("Invalid input\n");
            return 0;
        }
        Node* head = NULL;
        for(int i=0;i<n;i++){
            scanf("%s",input);
            if(!isValidInteger(input)){
                printf("Invalid input\n");
                return 0;
            }
            int num=atoi(input);
            if(num < -1000 || num > 1000){
                printf("Invalid input\n");
                return 0;
            }
            insertNode(&head,num);
        }
        displayList(head);
        return 0;
    }
}