#include<stdio.h>
#include<stdlib.h>
typedef struct node{
    int data;
    struct node *next;
    
}s1;
int count=0,found=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 deletion(int val){
    first=head;
    second=head->next;
    if(head->data == val){
        head=head->next;
        return 0;
    }else{
        while(head != NULL){
            if(second->data == val){
                first->next=second->next;
                break;
            }
            first=first->next;
            second=second->next;
            
            if(second==NULL){
                flag=1;
            }
        }
    }
    
}
int display(int size){
    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);
    deletion(val);
    if(found==1){
        display(size);
    }else{
        printf("Node not found");
        return 0;
    }
   
    
}