#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;
            }
        }
        int value,pos;
        scanf("%d %d",&value,&pos);
        head=insertAtPosition(head,value,pos,n);
        if(head){
            printfList(head);
        }
        return 0;
    }
    }