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