#include<stdio.h>
#include<stdlib.h>
struct Node{
    int data;
    struct Node* next;
};
struct Node* create(int data){
    struct Node* n = malloc(sizeof(struct Node));
    n->data = data;
    n->next = NULL;
    return n;
}
struct Node* reverse(struct Node* head){
    struct Node *prev = NULL, *curr = head, *next;
    while(curr){
        next = curr->next;
        curr->next = prev;
        prev = curr;
        curr = next;
    }
    return prev;
}
void print(struct Node* head){
    for(; head; head = head->next)
    printf("Invalid input\n");
    return 0;
}
struct Node *head = NULL, *tail = NULL;
for(int i = 0; i < n; i++){
    scanf("%d", &x);
    struct Node* node = create(x);
    if(!head) head = tail = node;
    else tail = tail->next = node;
}
head = reverse(head);
print(head);
return 0;
}