#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;
}
void printList(struct Node* head){
    while(head != NULL){
        printf("%d ",head->data);
        head = head->next;
    }
    printf("\n");
}
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 = dat;
        newNode->next = NULL;
        if(head == NULL){
            head = newNode;
            temp = newNode;
        }else{
            temp->next = newNode;
            temp  = newNode;
        }
    }
    scanf("%d", &P);
    if(P < 0 || P >= N){
        printf("Invalid input\n");
        return 0;
    }
    deleteNode(&head, P);
    printList(head);
    return 0;
}