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