#include<stdio.h>
#include<stdlib.h>
void del(int pos);
void display();

typedef struct Node{
    int data;
    struct Node *next;
    
}node;

node *head=NULL;
node *tail;
node *newnode;
node *temp;
node *temp1;


void create(int num){
    newnode=(node*)malloc(sizeof(node));
    newnode->data=num;
    newnode->next=NULL;
    if(head==NULL){
      head = newnode;
      tail = newnode;
      
    }    
    else{
        tail->next=newnode;
        tail=newnode;
    }
}

void del(int pos){
    temp=head;
    temp1=head->next;
    if(pos==temp->data){
        head=temp1;
    }
    while(temp1!=NULL){
        if(temp1->data==pos){
            temp->next=temp1->next;
            break;
        }
        temp=temp->next;
        temp1=temp1->next;
        
    }
    
}

void display(){
    node *itr;
    for(itr=head;itr!=NULL;itr=itr->next){
        printf("%d ",itr->data);
    }
}
int main(){
    int size;
    int num,ind,pos;
    int found
    scanf("%d",&size);
    for(ind=0;ind<size;ind++){
        scanf("%d",&num);
        create(num);
    }
    scanf("%d",&pos);
    del(pos);
    if(pos==0){
        printf("Node not found");
        return 0;
    }
    display();
    return 0;
}