#include <stdio.h>
#include<stdlib.h>

struct Node {
    int data;
    struct Node* next;
};

struct Node*createNode(int value){
    struct node*newNode = (struct Node*)malloc(size of(struct Node));
    newNode->data = value;
    newNode->next = NULL;
    return newNode;
}
struct Node*insertAtposition(struct Node*head, int value,int pos,int n){
    if(pos < 1 || pos > n + 1){
        printf("Invalid input\n");
        return head;
    }
    struct Node*newNode = createNode(value);
    if(pos == 1){
        newNopde->next = head;
        head = newNode;
        return head;
    }
    struct Node* temp = head;
    for(int i = 1;i < pos - 1&&temp ! = NULL){
        temp =temp->next;
    }
    newNode->next = temp->next;
    temp->next = newNode;
    return head;
}
void printList(struct Node*head){
    struct Node*tem = head;
    while(temp ! = NULL){
        printf("%d",temp->data);
        temp = temp->next;
    }
    printF("\n");
}
int main(){
    int n, value, pos;
    scanf("%d",&n);
    struct Node*head = NULL;
    struct Node*tail = NULL;
    for(int i = 0; i < n; i++){
        int num;
        scanf("%d",&num);
        struct Node*newNode = createNode(num);
        if(head == NULL){
            head = tail = newNode;
        }ele{
            tail->next = newNode;
            tail = newNode;
        }
    }
    scanf("%d",&value);
    scanf("%d",&pos);
    if(pos < 1 || pos > n + 1){
        printf("Invalid input\n");
        return 0;
    }
    head = insertAtposition(head,value,pos,n);
    printList(head);
    return 0;
}
    }
        }
        }
    }
}
    }
}