#include<stdio.h>
#include<stdlib.h>
typedef struct Node{
    int data;
    struct Node*next;
}Node;
Node*createNode(int data){
    Node*newNode=(Node*)malloc(sizeof(Node));
    newNode->data=data;
    newNode->next=NULL;
    return newNode;
}
Node*delete_at_position(Node*head,int P,int N){
    if(P<0||P<=N) return NULL;
    if(P==0){
        Node*temp=head;
        head=head->next;
        free(temp);
    }
else{
    Node*current=head;
    for(int i=0;i<p-1;i++){
        current=current->next;
    }
    Node*temp=current->next;
    current->next=current->next->next;
    free(temp);
}
return head;
}
void print_list(Node*head){
    while(head){
        printf("%d",head->data);
        head=head->next;
    }
    printf("\n");
}
int main()
{
    int N;
    scanf("%d",&N);
    if(N<=0){
        printf("Invalid input\n");
        return 0;
    }
    Node*head=NULL;
    Node*current=NULL;
    for(int i=0;i<N;i++){
        int data;
        scanf("%d",&data);
        if(!head){
            head=currentNode(data);
            current=head;
        }
        else
        {
            current->next=createNode(data);
            current=current->next;
            
        }
        }
        int P;
        scanf("%d",&P);
        if(P<0||P>=N){
            printf("Invalid input\n");
        }
        else
        {
            head-delete_at_position(head,P,N);
            printf_list(head);
        }
        return 0;
    }