#include<stdio.h>
#include<stdlib.h>
struct Node{
    int data;
    struct Node* next;
};
struct Node* createNode(int data){
    struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
    newNode->data = data;
    newNode->next = NULL;
    return newNode;
}
struct Node* deleteNode(struct Node* head, int roll){
    if(head == NULL){
        printf("List is empty");
        return NULL;
    }
    struct Node* temp = head;
    struct Node* prev = NULL;
    if(temp != NULL && temp->data == roll){
        head = temp->next;
        free(temp);
        if(head == NULL)
            printf("List is empty");
        else{
            struct Node* curr = head;
            while(curr != NULL){
                printf("%d", curr->data);
                if(curr->next != NULL){
                    printf(" ");
                curr = curr->next;
                }
            }
        return head;
     }
    while (temp != NULL && temp->data != roll){
        prev = temp;
        temp = temp->next;
    }
    if(temp == NULL){
        printf("Not Found");
        return head;
    }
    prev->next = temp->next;
    free(temp);
    if (head == NULL){
        printf("List is empty");
        return NULL;
    }
    struct Node* curr = head;
    while(curr != NULL){
        printf("%d", curr->data);
        if(curr->next != NULL)
            printf(" ");
        curr = curr->next;
        }
    return head;
}
int main(){
    int n, val, toDelete;
    if(scanf("%d", &n) != 1 || n < 1 || n > 10){
        printf("Invalid input");
        return 0;
    }
    struct Node* head = NULL;
    struct Node* tail = NULL;
    for (int i = 0; i < n; i++){
        if(scanf("%d", &val) !=1 || val < -10000 || val > 10000){
            printf("Invalid input");
            return 0;
        }
        struct Node* newNode = createNode(val);
        if(head == NULL){
            head = tail = newNode;
        }else{
            tail->next = newNode;
            tail = newNode;
        }
    }
    if(scanf("%d", &toDelete) !=1 || toDelete < -10000 || toDelete > 10000){
        printf("Invalid input");
        return 0;
    }
    head = deleteNode(head, toDelete);
    
    return 0;
}