#include<stdio.h>
 #include<stdlib.h>
 struct Node{
     int data;
     struct Node* next;
 };
void deleteNode(struct Node** head_ref,int position){
    if(*head_ref == NULL)
    return;
    struct Node* temp= *head_ref;
    if(position == 0){
        *head_ref = temp->next;
        free(temp);
        return;
    }
    for(int i = 0; temp != NULL && i < position -1; i++)
    temp = temp->next;
    if(temp == NULL || temp->next == NULL)
    return;
    struct Node* next = temp->next->next;
    free(temp->next);
    temp->next = next;
}
 int main(){
     int N,P;
     scanf("%d", &N);
     if(N <= 0){
         printf("Invalid input\n");
         return 0;
     }
   struct Node* head = NULL;  
    struct Node* temp = NULL;  
    for(int i = 0; i < N; i++){
        int data;
        scanf("%d", &data);
        struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
        newNode->data = data;
        newNode->next = NULL;
        if(head == NULL){
            head = newNode;
            temp = head;
        }else{
            temp->next = newNode;
            temp = newNode;
        }
    }
    scanf("%d", &p);
        if(p < 0 || p >= N){
        printf("Invalid input\n");
        return 0;
    }
    deleteNode(&head, p);
    int List(head);
    return 0;
     
 }