// editor3
#include<stdio.h>
#include<stdlib.h>
typedef struct lst
{
    int data;
    struct lst *next;
}node;

node*head=NULL,*tail=NULL;
void create(int n)
{
    node *nd=(node*)malloc(sizeof(node));
    nd->data=n;
    nd->next=NULL;
    if(head==NULL)
    {
        head=tail=nd;
    }
    else
    {
        tail->next=nd;
        tail=nd;
    }
}

void ins(int n,int val)
{
    node *nd=(node*)malloc(sizeof(node));
    nd->data=val;
    nd->next=NULL;
    node *temp=head;
    for(int i=0;i<n;i++)
    {
        temp=temp->next;
    }
    
    nd->next=temp->next;
    temp->next=nd;
}

void print()
{
    node *temp=head;
    while(temp!=NULL)
    {
        printf("%d ",temp->data);
    }
}

int main()
{
    int n,val,pos;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        int data;
        scanf("%d",&data);
        create(data);
            
    }
    scanf("%d",&pos);
    if(pos<0)
        {
            printf("Invalid input");
            return 0;
        }
    scanf("%d",&val);
    ins(pos,val);
    print();
}