#include<stdio.h>
#include<stdlib.h>
typrdef struct node
{
    int data;
    struct node*prev;
    struct node*next;
}
node;
node*createnode(int data)
{
    node*newnode=
    (node*)malloc(size of(node));
    newnode->data=data;
    newnode->prev=newnode->next=NULL;
    return newnode;
}
void insertend(node**head,node**tail,int data)
{
    node*newnode=createnode(data);
    if(*head==NULL)
    {
        *head=*tail=newnode;
    }
    else
    {
        (*tail)->next=newnode;
        newnode->prev=*tail;
        *tail=newnode;
    }
}
void printlist(node*head)
{
    node*temp=head;
    while(temp!=NULL)
    {
        printf("%d",temp->data);
        if(temp->next!=NULL)
        printf(" ");
        temp=temp->next;
    }
}
int main()
{
    int n;
    if(scanf("%d",&n)!=1||n<=0)
    {
        printf("Invalid input");
        return 0;
    }
    node*head=NULL;
    node*tail=NULL;
    for(int i=0;i<n;i++)
    {
        int val;
        if(scanf("%d",&val)!=1)
        {
            printf("Invalid input");
            return 0;
        }
        insertend(&head,&tail,val);
    }
    printflist(head);
    return 0;
}
        }
    }
    }
}
    }
}
    }
    }
}
}
}