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