#include <stdio.h>
#include <stdlib.h>

typedef struct node {
    int val;
    struct node *next;
} Node;

Node *head=NULL;

Node* createN(int x){
    Node *newnode;
    newnode = (Node*)malloc(sizeof(Node));
    newnode->val=x;
    newnode->next=NULL;
    return newnode;
}

void freeL(void){
    Node *p;
    while(head !=NULL){
        p=head->next;
        free(head);
        head=p;
    }
}

void printL(void){
    Node *p=head;
    while(p !=NULL){
        printf("%d",p->val);
        p = p->next;
    }
    printf("\n");
}

void makeL(int n,int a[]){
    if(n==0) return;

    Node *p;
    head=createN(a[0]);
    p = head;

    for (int i=1;i<n;i++){
        p->next=createN(a[i]);
        p=p->next;
    }
}

int main(void){
    int i, n;
    int *a;

    scanf("%d",&n);
    a=(int *)malloc(sizeof(int)*n);

    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }

    makeL(n,a);
    printL();
    freeL();
    free(a);  

    return 0;
}