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