#include <stdio.h>
#include <stdlib.h>
struct node{
    int data;
    struct node* next;
};
struct node*head = NULL;
struct node*temp;
struct node*temp1;
void create(int data){
    struct node* newnode=(struct node*)malloc(sizeof(struct node));
    newnode->data=data;
    newnode->next=NULL;
    if(head==NULL)
    {
        head=newnode;
    }
    else{
        temp=head;
        while(temp->next!=NULL)
        {
            temp=temp->next;
        }
        temp->next=newnode;
    }
}
void display(){
    temp=head;
    while(temp!=NULL)
    {
        printf("%d ",temp->data);
        temp=temp->next;
    }
}
void deletion(int pos){
    
   
    temp=head;
    temp1=temp;
   
        while(temp!=NULL){
            if(temp==pos){
                temp1->next=temp->next;
                break;
            }
            free(temp);
            
        
        temp1->next=temp;
        temp=temp->next;
    }
}
int main(){
    int n,i,data;
    int pos;
    scanf("%d",&n);
    if( n<0){
        printf("Invalid input");
        return 0;
    }
    for(i=0;i<n;i++){
        scanf("%d",&data);
            return 0;
        }
        create(data);
     scanf("%d",&pos);
     if(pos<0 ||pos>=n){
         printf("Invalid input");
         return 0;
     }
    
        
    
   
     deletion(pos);
     display();
     return 0;
}