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