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