#include<stdio.h>
#include<stdlib.h>
 typedef struct Node{
     int data;
     struct Node*next;
 }Node;
 Node *head=NULL,*tail;
 struct Node* createNode(int data){
     struct Node*newNode=(struct Node*)malloc(sizeof(struct Node));
     newNode->data=data;
     newNode->next=NULL;
     return newNode;
 }
 struct Node* insertAtBeginning(struct Node* head,int valueToInsert){
     struct Node* newNode=createNode(valueToInsert);
     struct node* temp;
     if(head==NULL){
         newNode->next=newNode;
         return newNode;
     }
temp=*head;
     while(temp->next!=head){
         temp=temp->next;
     }
     temp->next=newNode;
     newNode->next=head;
     head=newNode;
     return head;
 }
 void print(struct Node* head){
 if(head==NULL)
 return ;
 struct Node* temp;
     int arr[1000];
     int count;
     int i;
     
     temp=head;
     count=0;
 do{
     arr[count++]=temp->data;
     temp=temp->next;
     
 }while(temp!=head);
 for(int i=0;i<count;i++){
     printf("%d",arr[i]);
 }
 }
 int main(){
     int n;
     scanf("%d",&n);
     if(n<=0){
         printf("Invalid input");
         return 0;
     }
     struct Node* head=NULL;
     struct Node* temp=NULL;
     struct Node* newNode;
     for(int i=0;i<n;i++){
         int val;
         scanf("%d",&val);
         newNode=createNode(val);
         
         if(head==NULL){
             head=newNode;
             tail=newNode;
         }
         else{
             temp->next=newNode;
             temp=newNode;
         }
         
     }
     temp->next=head;
     int valToInsert;
     scanf("%d",&valToInsert);
     head=insertAtBeginning(head,valToInsert);
     int arr[1000],count=0;
     temp=head;
     do{
         arr[count++]=temp->data;
         temp=temp->next;
}while(temp!=head);
   for( int i<0;i<count;i++) {
       printf("%d",arr[i]);
   } 
     return 0;
 }