#include<stdio.h>
#include<stdlib.h>
struct Node{
    int data;
    struct Node*next;
    
};
struct Node* createNode(int data){
    struct Node* newNode=(struct Node*)malloc(sizeof(struct Node));
    newNode->data=data;
    newNode->next=NULL;
    return newNode;
}
int main(){
    int n,i,valueToInsert;
    scanf("%d",&n);
    if(n<=0){
        printf("Invalid input");
        return 0;
    }
    int values[100];
    for(i =0;i<n;i++){
        scanf("%d",&values[i]);
    }
    scanf("%d",&valueToInsert);
    struct Node* head=createNode(values[0]);
    struct Node*tail=head;
    for(i=1;i<n;i++){
        tail->next=createNode(values[i]);
        tail=tail->next;
    }
    tail->next=head;
    struct Node*newHead=createNode(valueToInsert);
    newHead->next=tail;
    head=newHead;
    struct Node*temp=Head;
    head=tail;
    tail=temp;
    for(i=0;i<n+1;i++){
        printf("%d",temp->data);
        if(i!=n)
        printf(" ");
        temp=temp->next;
    }
    return 0;
}