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