#include<stdio.h>
#include<stdio.h>
typedef struct Node{
    int data;
    struct Node *next;
} Node;

int main(){
    int n, x;
    if (scanf("%d", &n) != 1 || n <= 0){
        printf("Invalid input\n");
        return 0;
    }
    
    Node *head = NULL, *tail = NULL, *p;
    
    for(int i = 0; i < n; i++){
        if(scanf("%d", &x) != 1){
            printf("Invalid input\n");
            return 0;
        }
        p = (Node*)malloc(sizeof(Node));
        if (!p){
            printf("Memory allocation failed\n");
            return 0;
        }
        p->data = x; 
        p->next = NULL;
        if (!head){
            head = tail = p;
        }else{
            tail->next = p;
            tail = p;
        }
    }
    for(p = head; p; p = p->next){
        printf("%d ", p->data);
        if(p->next)printf(" ");
    }
    printf("\n");
    
    while (head){
        p = head;
        head = head->next;
        free(p)
    }
    p = head;
    while (p){
        Node *tmp = p;
    }