#include <stdio.h>
#include <stdlib.h>
struct node
{
int data;
struct node *next;
};
int main()
{
int num[1000];
int n;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%d",&num[i]);
}
int box=num[0];
num[0]=num[1];
num[1]=box;
box=num[n-1];
num[n-1]=num[n-2];
num[n-2]=box;
struct node *head=(struct node *)malloc(sizeof(struct node));
if(head==NULL)
exit(1);
head->next=NULL;
struct node *t=head;
for(int j=0;j<n;j++)
{
struct node *p=(struct node *)malloc(sizeof(struct node));
if(p==NULL)
exit(1);
p->data=num[j];
p->next=NULL;
t->next=p;
t=t->next;
}
t=head->next;
while(t!=NULL)
{
printf("%d ",t->data);
t=t->next;
}
return 0;
}