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