#include <stdio.h>
#include <stdlib.h>
typedef struct Node{
    int data;
    struct Node*next;
}Node;
Node* createNode(int data){
    Node* newNode = (Node*)malloc(sizeof(Node));
    newNode->data=data;
    newNode->next=NULL;
    return newNode;
}
void printList(Node*head){
    while (head){
        printf("%d ",head->data);
        head=head->next;
    }
    printf("\n");
}

Node * insertAtPosition(Node*head,int value,int pos,int n){
    if(pos<1 || pos>n+1){
        printf("Invalid input\n");
        return NULL;
    }
    Node* newNode= createNode(value);
    if(pos==1){
        newNode->next=head;
        return newNode;
    }
    Node*temp=head;
    for(int i=1;i<pos-1;i++){
        temp=temp->next;
    }
    newNode->next=temp->next;
    temp->next=newNode;
    return head;
}
int main(){
    int n;
    scanf("%d",&n);
    Node*head=NULL;
    Node*temp=NULL;
    
    for(int i=0;i<n;i++){
        int data;
        scanf("%d",&data);
        if(!head){
            head=createNode(data);
            temp=head;
        }else{
            temp->next=createNode(data);
            temp=temp->next;
        }
    }
    
    int value,pos;
    scanf("%d",&value);
    scanf("%d",&pos);
    Node*head=createList(arr,n);
    head=insertAtPosition(head,value,pos,n);
    if(head){
        printList(head);
    }
    return 0;
}