#include<stdio.h>
#include<stdlib.h>
struct node
    {
        int data;
        struct node *next;
      };
    struct node*createnode(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
        return newnode;
        }
        void reverse(struct node** head,int value)
        {
            struct node*newnode=createnode(value);
            newnode->next=*head;
            *head=newnode;
        }
    int main()
    {
        int n;
        scanf("%d",&n);
        struct node*head=NULL;
        for(int i=0;i<n;i++){
            int value;
            if(scanf("%d",&value)!=1)
            {
                printf("Invalid input");
                return 0;
        }
        reverse(&head, value);
    }
    struct node*temp=head;
    while(temp!=NULL)
    {
        printf("%d",temp->data);
        if(temp->next!=NULL)
        printf(" ");
        temp=temp->next;
    }
    printf("\n");
    temp=head;
    while(temp!=NULL){
        struct node*next=temp->next;
        free(temp);
    }
    //return 0;
}