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