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