#include<stdio.h>
#include<stdlib.h>
struct Node{
    int data;
    struct Node *next;
};
struct Node* insertEnd(struct Node *head,int value){
    struct Node *newNode=malloc(size(struct Node));
    newNode->data=value;
    newNode->next=NULL;
    if(head==NULL)return newNode;
    struct Node *temp=head;
    while(temp->next!=NULL)
    temp=temp->next;
    temp->next=newNode;
    return head;
}
struct Node* deleteAtPos(struct Node *head,int P)
{
    if(head==NULL)
    return NULL;
    if(P==0){
        struct Node *temp=head;
        head=head->next;
        free(temp);
        return head;
    }
    struct Node *curr=head;
    for(int i=0;curr!=NULL&&i<P-1;i++)
    return head;
    struct Node *temp=curr->next;
    curr->next=temp->next;
    free(temp);
    return head;
}
void printList(struct Node *head){
    if(head==NULL)return;
    struct Node *temp=head;
    while(temp!=NULL){
        printf("%d ",temp->data);
        temp=temp->next;
    }
}
int main(){
    int N,P,x;
    struct Node *head=NULL;
    if(scanf("%d",&N)!=1)return 0;
    if(N<=0){
        printf("Invalid input");
        return 0;
    }
    for(int i=0;i<N;i++){
        scanf("%d",&x);
        head=insertEnd(head,x);
    }
    if(scanf("%d",&P)!=1)return 0;
    if(P<0||P<N||head==NULL){
        printf("Invalid input");
        return 0;
    }
    head=deleteAtPos(head,P);
    printList(head);
    return 0;
}