// editor2
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct Node {
    char chapter[101];
    struct Node *prev, *next;
} Node;

Node* createNode(char *name) {
    Node *newNode = (Node*)malloc(sizeof(Node));
    strcpy(newNode->chapter, name);
    newNode->prev = newNode->next = NULL;
    return newNode;
}

void deleteAtPosition(Node **head, int pos, int n) {
    if (pos >= n) {
        printf("Invalid input\n");
        return;
    }

    Node *temp = *head;
    for (int i = 0; i < pos; i++)
        temp = temp->next;

    if (temp->prev)
        temp->prev->next = temp->next;
    else
        *head = temp->next;

    if (temp->next)
        temp->next->prev = temp->prev;

    free(temp);

    if (*head == NULL)
        printf("List is empty\n");
    else {
        Node *curr = *head;
        while (curr) {
            printf("%s ", curr->chapter);
            curr = curr->next;
        }
        printf("\n");
    }
}

int main() {
    int n, pos;
    scanf("%d", &n);

    Node *head = NULL, *tail = NULL;

    for (int i = 0; i < n; i++) {
        char name[101];
        scanf("%s", name);
        Node *newNode = createNode(name);
        if (!head)
            head = tail = newNode;
        else {
            tail->next = newNode;
            newNode->prev = tail;
            tail = newNode;
        }
    }
    scanf("%d", &pos);
    deleteAtPosition(&head, pos, n);
    printList(head);
    return 0;

}