#include <stdio.h>
#include <stdlib.h>
typedef struct node{
    int data;
    struct node *next;
}nod;
nod *head =NULL,*temp=NULL,*newNode=NULL;
int found=0;
void deleteByVal(int val){
    nod *first,*second;
    first=head;
    second=head->next;
    if(val==first->data){
        head=head->next;
    }else{
        while(second!=NULL){
            if(second->data==val){
                first->next=second->next;
                found=0;
                break;
            }
            first=second;
            second=second->next;
            found=1;
        }
    }
}
void display(){
    temp=head;
     if(found==1){
        printf("Not found");
    }else if(head==NULL){
        printf("List is empty");
    }
    }else{
        while(temp!=NULL){
        printf("%d ",temp->data);
        temp=temp->next;
    }
    }
    
}
int main(){
    int n;
    scanf("%d",&n);
    if(n<0){
        printf("Invalid Input");
        return 0;
    } 
    
    for(int i=0;i<n;i++){
        int x;
        if(scanf("%d",&x)!=1){
            printf("Invalid Input");
            return 0;
        }
        newNode=(nod*)malloc(sizeof(nod));
        newNode->data=x;
        newNode->next=NULL;
        
        if(head==NULL){
            head=newNode;
            temp=newNode;
        }else{
            temp->next=newNode;
            temp=temp->next;
        }
    }
    int x;
    scanf("%d",&x);
    deleteByVal(x);
    display();
    return 0;
}