#include <stdio.h>
#include <stdlib.h>
typedef struct Node{
    int data;
    struct Node* next;
}Node;

Node *head=NULL,*tail,*adu, *temp;

void create(int num){
    Node *new = (Node*)malloc(Node);
    new->data=num;
    new->next=NULL;
    
    if(head==NULL){
        head = new;
        tail = new;
    }
    else{
        tail->next=new;
        tail=new;
    }
}

void display(){
    Node *i;
    for(i=head;i!=NULL;i=i->next){
        printf("%d ",i->data);
    }
}

void insert(int val, int pos){
    Node *new = (Node*)malloc(Node);
    new->data = val;
    new->next = NULL;
    
    temp = head;
    for(int i=1;i<pos-1;i++){
        temp = temp->next;
    }
    adu = temp->next;
    
    new->next = adu;
    temp->next = new;
}

int main(){
    int n,num,i,val,pos;
    scanf("%d",&n);
    if(n<=0){
        printf("Invalid input");
        return 0;
    }
    
    for(i=1;i<=n;i++){
        if(!(scanf("%d",&num))){
            printf("Invalid input");
            return 0;
        }
        create(num);
    }
    scanf("%d %d",&val,&pos);
    if(pos<0 || pos>n){
        printf("Invalid input");
        return 0;
    }
    
    insert(val,pos);
    display();
    return 0;
}