#include<stdio.h>
#include<stdlib.h>
struct node 
{
    int data;
    struct node* prev;
    struct node* next;
};
struct node* cre(int val)
{
    struct node* newnode = (struct node*)malloc (sizeof(struct node));
    newnode->data = val;
     newnode->prev = NULL;
      newnode->next = NULL;
      return newnode;
}
struct node*  instert(struct node* head,int val)
{
    struct node* newnode = cre(val);
    if(head == NULL)
    return newnode;
    struct node* temp = head;
    while(temp->next != NULL)
    temp = temp->next;
    
    temp->next = newnode;
    newnode->prev = temp;
    return head;
}
int main()
{
    int n,val;
    struct node* head = NULL;
    if(scanf("%d",&n) != 1 || n <= 0)
    {
        printf("Invalid input");
        return 0;
    }
    for(int i = 0;i < n; i++)
    {
        if(scanf("%d",&val) != 1)
        {
           printf("Invalid input");
        return 0;  
        }
    }
    head = insert(head,val);
}
struct node* temp = head;
while(temp != NULL)
{
    printf("%d"\n,temp->data);
    temp = temp->next;
}
return 0;
}