#include <stdio.h>
#include <stdlib.h>
typedef struct node{
    int data;
    struct node *next;
}nod;
nod *head =NULL,*temp=NULL,*newNode=NULL;
void deletebypos(int pos){
    if(pos==0){
        temp=head;
        head=head->next;
        free(temp);
    }
    nod *first=head,*second;
    for(int i=head;i<=pos-1;i++){
        first=first->next;
    }
    
    
}
void display(){
    temp=head;
    while(temp!=NULL){
        printf("%d ",temp->data);
        temp=temp->next;
    }
}
int main(){
    int n;
    scanf("%d",&n);
    if(n<0){
        printf("Invalid input");
        return 0;
    } 
    
    for(int i=0;i<n;i++){
        int x;
        if(scanf("%d",&x)!=1){
            printf("Invalid input");
            return 0;
        }
        newNode=(nod*)malloc(sizeof(nod));
        newNode->data=x;
        newNode->next=NULL;
        
        if(head==NULL){
            head=newNode;
            temp=newNode;
        }else{
            temp->next=newNode;
            temp=temp->next;
        }
    }
    int p;
    scanf("%d",&p);
    deletebypos(p);
    display();
    return 0;
}