// editor5
#include<stdio.h>
#include<stdlib.h>
struct Node{
    int data;
    struct Node* next;
};
int main(){
    int N;
    scanf("%d",&N);
    if(N<=0){
        printf("Invalid input");
        return 0;
    }
    struct Node *head = NULL, *tail = NULL;
    for(int i=0;i<N;i++){
        int val;
        scanf("%d",&val);
        struct Node* newNode = (struct Node *)malloc(sizeof(struct Node));
        newNode->data = val;
        newNode->next = NULL;
        if(head == NULL){
            head = tail = newNode;
        }
        else{
            tail->next = newNode;
            tail = newNode;
        }
    }
    int P;
    scanf("%d",&P);
    if(P<0 || P>=N){
        printf("Invalid input");
        return 0;
    }
    if(P == 0){
        struct Node* temp = head;
        head = head->next;
        free(temp);
    }
    else{
        struct Node* curr = head;
        for(int i=0;i<P-1;i++){
            curr = curr->next;
        }
        struct Node* temp = curr->next;
        curr->next = temp->next;
        free(temp);
    }
    struct Node* curr = head;
    while(temp != NULL){
        printf("%d ",temp->data);
        temp = temp->next;
    }
    return 0;
}