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