#include<stdio.h>
#include<stdlib.h>

typedef struct Node {
    int data;
    struct Node* next;
} Node;

void inser(Node** h, int d){
    Node* n = malloc(sizeof(Node));
    n->data = d; n->next = NULL;
    if(!*h) *h = n; else {
        Node8 t = *h;
        while(t->next) t = t->next;
        t->next = n;
    }
}
void deletePos(Node** h, int p){
    if(!*h) { printf("Invalid input\n"); return; }
    Node* t = *h;
    if(p == 0) { *h = t->next; free(t); return; }
    for(int i = 0; t&& i < p - 1; i++) t = t->next;
    if(!t || !t->next) { printf("Invalid input\n"); return; }
    Node*toDel = t->next;
    t->next = toDel->next;
    free(toDel);

}

void print(Node* h){
    while(h) { printf("%d ",h->data); h= h->next; }
    printf("\n");
}
int main(){
    int N, P; Node* head = NULL;
    if(scanf("%d", &N) != 1 || N < 0 || N > 100) { printf("Invalid input\n"); return 0; }
    for(int i = 0; i < N; i++) { int r; scanf("%d",&r); insert(&head,r); }
    if (scanf("%d", &P) !=1 || P < 0 || P>=N) { printf("Invalid input\n"); return 0; }
    deleteAtpos(&head, P);
    printf(head);
    return 0;
    
}