#include<stdio.h>
#include<stdlib.h>
struct node
{
    int data;
    struct node *next;
};

int main()
{
    int n,val,x;
    scanf("%d"&n);
    if(n <= 0)
    {
        printf("Invalid output");
        return 0;
    }
    struct node *head = NULL,*tail = NULL,*temp;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&val);
        temp = (struct node*)malloc(sizeof(struct node));
        temp->data = val;
        temp->next = NULL;
        if(!head)
        {
            head = tail = temp;
            tail->next = head;
        }
        else
        {
            tail->next = temp;
            tail->next = head;
            tail = temp;
        }
    }
    scanf("%d",&x);
    temp = (struct node*)malloc(sizeof(struct node));
    temp->data  = x;
    temp->next = head;
    tail->next = temp;
    head = temp;
    temp = head;
    do{
        printf("%d ",temp->data);
        temp = temp->next;
    }while(temp != head);
    return 0;
}