// editor3
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
typedf struct Node
{
    int data;
    struct Node* prev;
    struct Node* next;
}Node;
Node*createNode(int data)
{
    Node* newnode=(Node*)malloc(sizeof(Node));
    if(!newNode){
        printf("memory allocation error\n");
        exit(1);
    }
    newNode->data=data;
    newNode->prev=NULL;
    newNode->next=NULL;
    return newNode;
}
void insertEnd(Node** head,int data)
{
    Node* newNode=createNode(data);
    if(*head==NULL)
    {
        *head=newNode;
        return;
    }
    Node* temp=head;
    while(temp->next !=NULL)
    {
        printf("%d",temp->data);
        temp=temp->next;
    }
    printf("\n");
    }
    int main()
    {
        int n;
        if(scanf("%d",&n)!=1 ||n<=0)
        {
            printf("Invalid input\n");
            return 0;
        }
        Node* head=NULL;
        for(int i=0;i<n;i++)
        {
            int val;
            if(scanf("%d",&val)!=1)
            {
                printf("Invalid input\n";);
                return 0;
            }
            insertEnd(&head,val);
        }
        printlist(head);
        return 0;
    }
            }