#include<stdio.h>
#include<stdlib.h>
struct node{
    int data;
    struct node*next;
}*head=NULL,*tall=NULL;
int main(){
    int n,val,input;
    if(scanf("%d",&n) !=1||n<0||n>1000){
        printf("Invalid input");
        return 0;
    }
    for (int i=0;i<n;i++){
        if(scanf("%d",&input) !=1){
            printf("Invalid input");
            return 0;
        }
        struct node *newNode =(struct node*)malloc(sizeof(struct node));
        newNode->data = input;
        newNode->next = NULL;
        
        if (head == NULL){
            head = tall=newNode;
        } else{
            tall->next=newNode;
            tall=newNode;
        }
    }
    if(scanf("%d",&val)!=1){
        printf("Invalid input");
        return 0;
    }
    if (head==NULL){
        printf("List is empty");
        return 0;
    }
    struct node*temp =head,*prve=NULL;
    int found=0;
    
    while(temp !=NULL){
        if (temp->data == val){
            found = 1;
            if(prev==NULL){
                head = head->next;
            } else{
                prev->next=temp->next;
            }
            free(temp);
            break;
        }
        prev = temp;
        temp = temp->next;
    }
    if(!found){
        printf("Value not found");
    }else if(head == NULL){
        printf("List is empty");
    }else{
        temp =  head;
        while (temp!=NULL){
            printf("%d",temp->data);
            temp=temp->next;
        }
    }
    return 0;
}