#include<stdio.h>
#include<stdlib.h>

struct Node{
    int data;
    struct Node* next;
};
struct Node*createnode(int value){
 struct Node* new=(struct Node*)malloc(sizeof(struct Node));
 new->data=value;
 new->next=NULL;
 return new;
 }
 struct Node* insertAtPosition(struct Node* head,int value,int pos){
     if(pos<1||pos>n){
         printf("Invalid input\n");
         exit(0);
     }
     struct Node* new=createnode(value);
     if(pos==0){
         new->next=head;
         return new;
     }
     struct Node*temp=head;
     for(int i=1;i<pos-1&& temp !=NULL;i++){
     new->next=temp->next;
     temp->next=new;
     }
     return head;
 }
 void printList(struct Node*head){
     while(head!=NULL){
         printf("%d",head->data);
         head=head->next;
     }
     printf("\n");
 }
 int main(){
     int n;
     scanf("%d",&n);
     if(n<0){
         printf("Invalid input\n");
         return 0;
     }
     struct Node*head=NULL;
     struct Node*temp=NULL;
     for(int i=0;i<n;i++){
      int val;
    scanf("%d",&val);
    struct Node* n=createnode(val);
    if(head==NULL)
     head=n;
     else
     temp->next=n;
     temp=n;
     }
     
int value,pos;
scanf("%d",&value);
scanf("%d",&pos);
head=insertAtPosition(head,value,pos,n);
printList(head);
return 0;
}