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