#include<stdio.h>
#include<stdlib.h>

typedef struct node{
    int data;
    struct node *next;
}s1;
struct node *head=NULL,*tail=NULL;
void create(int num){
    s1 *New=(s1*)malloc(1*sizeof(s1));
    New->data=num;
    New->next=NULL;
    if(head==NULL){
        head=New;
        tail=New;
    }else{
        tail->next=New;
        tail=New;
    }
}
void delete(int P,int **head_ref){
    *head_ref=head;
    s1 *prev=*head_ref;
    s1 *current=*head_ref;
    s1 *temp=head;
    if (P==1){
        head= head->next;
        free(temp);
        temp=NULL;
        return 0;
    }else{
        for(int i=1;i!=NULL;i++){
            temp = temp->next;
        }
        prev-temp->next
    }
    

}
void display(){
    s1 *i;
    for(i=head;i!=NULL;i=i->next){
        printf("%d ",i->data);
    }
}
int main(){
    int size,num;
    scanf("%d",&size);
    for(int i=1;i<=size;i++){
        scanf("%d/n",&num);
        create(num);
    }
    int P;
    scanf("%d",&P);
    delete(P);
    
    return 0;
}