// editor1
#include<stdio.h>
#include<stdlib.h>
typedef struct Node{
    int data;
    struct Node*next;
}Node;
int main(){
    int n;
    scanf("%d",&n);
    if(n<=0){
        printf("Node not found");
        return 0;
    }
    Node*head=NULL,*tail=NULL;
    for(int i-0;i<n;i++){
        int val;
        scanf("%d",&val);
        Node*newNode=(Node*)malloc(sizeof(Node));
        newNode->data=val;
        newNode->next=head;
        if(!head)head=newNode;
        if(tail)tail->next=newNode;
        tail=newNode;
    }
    int x;
    scanf("%d",&x);
    Node*current=head,*prev=tail;
    int found=0;
    
    for(int i=0;i<n;i++){
        if(current->data==x){
            found=1;
            if(current==head)head=head->next;
                prev->next=current->next;
                free(current);
                n--;
                break;
        }
        prev=current;
        current=current->next;
    }
    if(!found){
        printf("Node not found");
        return 0;
    }
    current=head;
    for(int i=0;i<n;i++){
        printf("%d",current->data);
        current=current->next;
    }
    return 0;
}