// editor3
//editor 3
#include <stdio.h>
#include <stdlib.h>
struct Node {
    int data;
    struct Node* next;
};
struct Node* createNode(int data) {
    struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
    newNode->data = data;
    newNode->next = NULL;
    return newNode;
}
void deleteAtPosition(struct Node** head, int pos, int n) {
    if (pos < 1 || pos > n) {
        printf("Invalid input");
        return;
    }
    struct Node* temp = *head;
    if (pos == 1) {
        *head = temp->next;
        free(temp);
        return;
    }
    for (int i = 1; i < pos - 1; i++) {
        temp = temp->next;
    }
    struct Node* toDelete = temp->next;
    temp->next = toDelete->next;
    free(toDelete);
}
void printList(struct Node* head) {
    struct Node* temp = head;
    while (temp != NULL) {
        printf("%d", temp->data);
        if (temp->next != NULL) printf(" ");
        temp = temp->next;
    }
}

int main() {
    int n, pos;
    scanf("%d", &n);

    struct Node* head = NULL;
    struct Node* tail = NULL;

    for (int i = 0; i < n; i++) {
        int val;
        scanf("%d", &val);
        struct Node* newNode = createNode(val);
        if (head == NULL) {
            head = tail = newNode;
        } else {
            tail->next = newNode;
            tail = newNode;
        }
    }
    scanf("%d", &pos);
    if (pos < 1 || pos > n) {
        printf("Invalid input");
        return 0;
    }
    deleteAtPosition(&head,pos,n);
    printList(head);
    return 0;
}