#include<stdio.h>
#include<stdlib.h>
#define maxsize 1000
typedef struct node
{
int data;
struct node* next;
}node,*linklist;
void creatl(linklist a,int b[],int n){
a->next=NULL;//头节点的下一个置为空
int c,i;
for(i=0;i<n;i++){
linklist p=(node *)malloc(sizeof(node));
scanf("%d",&c);
b[i]=c;
p->data=c;
p->next=a->next;//在中间插入
a->next=p;
}
} //头插法
void printl(linklist a,int n){
int i;
linklist p;
p=a->next;
for(i=0;i<n;i++){
printf("%d",p->data);
printf(" ");
p=p->next;
}
}
void prints(int b[],int n){
for(int i=n-1;i>=0;i--){
printf("%d",b[i]);
printf(" ");
}
}
int main(){
int n;
scanf("%d",&n);
int a[maxsize];
linklist head=(node *)malloc(sizeof(node));
head->next=NULL;
creatl(head,a,n);
printl(head,n);
printf("\n");
prints(a,n);
return 0;
}