#include<stdio.h>
#include<stdlib.h>

typedef struct Node{
    int data;
    struct Node *next;
}node;

node *head=NULL,*tail,*temp;

void create(int num){
    node *newNode = (node*)malloc(sizeof(node));
    newNode->data = num;
    newNode->next = NULL;
    
    if(head == NULL){
        head = newNode;
    }
    else {
        tail->next = newNode;
    }
    tail = newNode;
}

void display(){
    node *i;
    for(i=head; i!=NULL; i=i->next){
        printf("%d ",i->data);
    }
}

void insert(int num,int pos){
    temp = head;
    for(int i=0;i<pos-1;i++){
        temp = temp->next;
    }
    temp->data = num;
    temp->next = temp->nextt;
}

int main(){
    int n,num,insNum,pos;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&num);
        create(num);
    }
    scanf("%d\n%d",&insNum,&pos);
    insert(insNum,pos);
    display();
}