#include<stdio.h>
#include<stdlib.h>

typedef struct number{
    int data;
    struct number *next; 
}box;

box *head = NULL,*tail;

void create(int num){
    box *newNode = (box*) malloc (1* sizeof(box));
    newNode->data = num;
    newNode->next = NULL;
    if(head==NULL){
        printf("Invalid input");
    }
    else{
        tail->next = newNode;
        tail = newNode;
    }
}

void display(){
    box *itr;
    for(itr = head; itr!=NULL; itr = itr->next){
        printf("%d ",itr->data);
    }
}

int main(){
    int n,itr,num;
    scanf("%d",&n);
    if(n<=0 || n>1000){
        printf("Invalid input");
        return 0;
    }
    for(itr=0; itr<n; itr++){
        scanf("%d",&num);
    if(num<1 || num>1000){
        printf("Invalid input");
        return 0;
        }
    create(num);
    }
    scanf("%d",&p);
    if(p<1 || p>=n){
        printf("Invalid input");
        return 0;
    }
    del(p);
    display();
}