#include<stdio.h>
#include<stdlib.h>

typedef struct node{
    int data;
    struct node *next;
    struct node *prev;
}s1;
s1 *head=NULL,*tail=NULL;
void create(int num){
    s1 *new=(s1*)malloc(sizeof(s1));
    new->data=num;
    new->next=NULL;
    new->prev=NULL;
    if(head==NULL){
        head=new;
        tail=new;
    }else{
        new->prev=tail;
        tail->next=new;
        tail=new;
    }
}

void delete(int val){
    s1 *temp,*prev;
    temp=head;
    if(temp->data==val){
        head=temp->next;
    }else{
        while(temp!=NULL&&temp->data!=val){
            prev=temp;
            temp=temp->next;  
        }
        prev->next=temp->next;
    }
}
int search(val){
    s1 *temp=head;
    while(temp!=NULL){
        if(temp->data==val){
            flag++;
        }temp=temp->next;
    }
    if(flag==0){
        printf("Node not found");
        return 0;
    }
}
void display(){
    s1 *i;
    for(i=head;i!=NULL;i=i->next){
        printf("%d ",i->data);
    }
}

int main(){
    int size,val,num;
    scanf("%d",&size);
    for(int i=1;i<=size;i++){
        scanf("%d ",&num);
        create(num);
    }
    scanf("%d",&val);
    delete(val);
    display();
    search(val);
    return 0;
}