#include <stdio.h>
 #include <stdlib.h>
 struct Node{
     int data;
     struct Node *next;
 };
 struct Node* insertEnd(struct Node *head,int value){
     struct Node *newNode=malloc(sizeof(struct Node));
     newNode->data=value;
     newNode->next=NULL;
     if(head==NULL)return newNode;
     struct Node *temp=head;
     while(temp->next!=NULL)
     temp=temp->next;
     temp->next=newNode;
     return head;
 }
 struct Node* deletAtPos(struct Node *head,int p){
     if (head==NULL)
     return NULL;
     if(p==0){
         struct Node *temp=head;
         head=head->next;
         free(temp);
         return head;
     }
     struct Node *curr=head;
     for(int i=0; curr !=NULL && i<p-1;i++)
     curr=curr->next;
     if(curr ==NULL ||curr->next==NULL)
     return head;
     struct Node *temp=curr->next;
     curr->next=temp->next;
     free(temp);
     return head;
     
 }
 void printList(struct Node *head){
     if(head==NULL)return ;
     struct Node *temp=head;
     while (temp!=NULL){
         printf("%d ",temp->data);
         temp=temp->next;
     }
 }
 int main(){
     int n,p,x;
     struct Node *head=NULL;
     if(scanf("%d",&n)!=1)return 0;
     if (n<0){
         printf("Invalid input");
         return 0;
     }
     for (int i=0;i<n;i++){
         scanf("%d",&x);
         head=insertEnd(head,x);
     }
     if(scanf("%d",&p)!=1)return 0;
     if(p<0 ||p>=n||head==NULL){
         printf("Invalid input");
         return 0;
     }
     head=deleteAtpos(head,p);
     printList(head);
     return 0;
 }