#include<stdio.h>
#include<stdlib.h>

struct Node{
    int data;
    struct node *next;
};

struct node *head=NULL,*tail=NULL;
 
 void create(int val){
    struct node *newnode=(struct node*)malloc(sizeof(struct node));
     newnode->data=val;
     newnode->next=NULL;
     
     if(head==NULL){
         head==tail=newnode;
     }
     else{
         tail->next=newnode;
         tail=newnode;
     }
 }
 
 int countNodes(){
     int count=0;
     struct node *temp=head;
     while(temp !=NULL){
         count++;
         temp=temp->next;
     }
     return count;
 }
 void insertAtPos(int val,int pos){
     struct node *newnode=(struct node*)malloc(sizeof(struct node));
     newnode->data=val;
     if(pos==1){
         newnode->next=head;
         head=newnode;
         return;
     }
     struct node *temp=head;
     for(int i=1;i<pos-1;i++){
         temp=temp->next;
     }
     newnode->next=temp->next;
     temp->next=newnode;
 }
 
 void display(){
     struct node *temp=head;
     while(temp !=NULL){
         printf("%d",temp->data);
         temp=temp->next;
     }
 }
 
 
 int main(){
     int n,val,pos;
     scanf("%d",&n);
     for(int i=0;i<n;i++){
         scanf("%d",&val);
         create(val);
     }
     scanf("%d",&val);
     scanf("%d",&pos);
     int size=countNodes();
     
     if(pos<1||pos>size+1){
         printf("Invalid Input");
         
     }else{
         insertAtPos(val,pos);
         display();
     }
     return 0;
 }