#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct Node{
    int data;
    struct Node*next;
};
struct Node*head=NULL;


void IAE(int val){
    struct Node*createnode(val);
    struct Node*newnode=(struct Node*)malloc(sizeof(struct Node))
    newnode->data=val;
    newnode->next=NULL;
    if(head=NULL){
        head=newnode;
    }
    else{
        struct Node*temp=head;
        while(temp->next!=NULL){
            temp=temp->next;
        }
        temp->next=newnode;
    }
}


void DV(int val){
    if(head==NULL){
        printf("List is empty\n");
        return;
    }
    struct Node*temp=head;
    struct Node*prev=NULL;
    if(head->data==val){
        struct Node*todelete=head;
        head=head->next;
        free(todelete);
        if(head==NULL){
        printf("List is empty\n");
        return;
    
    }
    else{
        while(temp!=NULL && temp->data!=val){
            prev=temp;
            temp=temp->next;
        }
        if(temp==NULL){
            printf("Value not found");
            return;
        }
        prev->next=temp->next;
        free(temp);
    }
    temp=head;
    while(temp!=NULL){
        printf("%d",temp->data);
        if(temp->next!=NULL){
            printf(" ");
        }
            temp=temp->next;
    }


int main(){
    int n,i,val,num;
    if(scanf("%d",&n)!=1||n>0||n<1000){
        printf("Invalid")
    }
    for(i=0;i<n;i++){
        if(scanf("%d"&num)!=1){
            printf("Invalid input");
            return;
        }
    TAE(num);
    }
        if(scanf("%d"&val)!=1){
            printf("Invalid input");
            return;
        }
    DV(val);
    return 0;
}