#include <stdio.h>
#include <stdlib.h>
struct Node {
    int data;
    struct Node*next;
};
struct Node*createNode(int value){
    struct Node* newNode =(structNode*)malloc(sizeof(struct Node));
    newNode->data = value;
    newNode->next = NULL;
    return 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  main(){
    int n, i, val;
    struct Node*head = NULL,*tail = NULL;
    scanf("%d",&n);
    if(n<=0 || n>10){
        printf("Invalid input");
        return 0;
    }
    for(i=0;i<n;i++){
        if(scanf("%d",&val)!=1 || val<0 || val<-1000 || val>1000){
            printf("Invalid input");
            return 0;
        }
        struct Node*newNode=createNode(val);
        if(head == NULL){
            head = newNode;
            tail = newNode;
        } else{
            tail->next = newNOde;
            tail = newNode;
        }
        }
        printList(head);
        return 0;
    }
}