#include<stdio.h>
#include<stdlib.h>

typedef struct node{
    int data;
    struct node*next;
}Node;

Node*head=NULL,*tail;

  
    


void create(int num){
  
    Node*newNode = (Node*)malloc(1*sizeof(newNode));
    newNode->data=num;
    newNode->next=NULL;
    
    if(head==NULL){
        head=newNode;
        tail=newNode;
    }
    else{
        tail->next=newNode;
        tail = newNode;
    }
   
}
void findposition(int value){
    
    Node*itr=head;
    int pos=1;
     while(itr->data == value){
        printf("%d ",pos);
       return;
    }
     itr = itr->next;
     pos++;
    
}
void display(){
    Node*itr=head;
    while(itr != NULL){
        printf("%d ",itr->data);
        itr = itr->next;
    }
}
int deletion(int va){
    
    if(head==NULL){
        printf("List is Empty");
        return 0;
    }
    Node *first=head;
    Node *second=head->next;
    
    if(pos ==1){
        head=head->next;
        free(first);
        return 0;
    }
    else{
        while(second!=NULL){
            if(pos >= 2){
                first->next=second->next;
                free(second);
                return 0;
            }
            
            first=first->next;
            second=second->next;
            

        }
    }
}    

    int main(){
        int N,itr,pos=1,num;
        
        if( !scanf("%d",&N) || N<=0){
               printf("Invalid Input");
               return 0;
        }
           for(itr=0;itr<N;itr++){
               if(!scanf("%d",&num)){
                   printf("Node not found");
                   return 0;
               }
               create(num);
               
         
            }
             if( !scanf("%d",&pos)){
              printf("Node not found");
                 return 0;
             }
      
        
   
       
        deletion(pos);
        display();
        return 0;
    }