#include<stdio.h>
#include<stdlib.h>
struct Node{
    int data;
    struct Node *next;
};
struct Node* insertEnd(struct Node* head,int value){
    struct Node*newNode = (struct Node*)malloc(sizeof(struct Node));
    newNode->data=value;
    newNode->next=NULL;
    
    if(head == NULL)
    return newNode;
    
    struct Node* temp=head;
    while(temp->next !=NULL)
    temp=temp->next;
    
    temp->next=newNode;
    return head;
}
struct Node* deleteNode(struct Node* head,int key,int* found){
    struct Node *temp=head, *prev=NULL;
    *found =0;
    
    
    if(temp!=NULL && temp->data==key){
        head=temp->next;
        free(temp);
        *found = 1;
        return head;
    }
    while(temp!=NULL&&temp->data!=key){
        prev=temp;
        temp=temp->next;
    }
    if(temp==NULL)
    return head;
        
    prev->next=temp->next;
    free(temp);
    *found = 1;
    return head;
}
void printList(struct Node*node){
    struct Node* temp = head;
    while(temp != NULL){
        printf("%d",temp->data);
        temp=temp->next;
    }
}
int main(){
    int n,value, key,found;
    scanf("%d",&n);
    
    if(n<1||n>100){
        printf("Invalid input");
        return 0;
    }
    
    struct Node* head = NULL;
    
    for(int i=0;i<n;i++){
        scanf("%d",&value);
        if(value<-1000||value>1000){
            printf("Invalid input");
            return 0;
        }
        head = insertEnd(head,value);
    }
    scanf("%d",&key);
    head=deleteNode(head,key,&found);
    
    if(!found){
        printf("Node not found");
    }else{
        printList(head);
    }
    return 0;
}