#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 key){
    struct Node *temp =head, *prev = NULL;
    if(temp != NULL && temp->data == key) {
        head = temp->next;
        free(temp);
        return head;
    }
    while(temp != NULL && temp->data != key) {
        prev =temp;
        temp = temp ->next;
    }
    if(temp == NULL)
        return head;
     prev->next = temp->next;
     free(temp);
     return head;
}
voiu printList(struct Node* head){
    if(head == NULL) {
        printf("List is empty");
        return;
    }
    struct Node* temp = head;
    while(temp != NULL){
        printf("%d", temp->data);
        if(temp->next != NULL)
            printf(" ");
        temp = temp->next;
    }
}
int main(){
    int n, toDelete;
    scanf("%d", &n);
    if(n <= 0 || n > 10){
        printf("Invalid Input");
        return 0;
    }
    struct Node* head = NULL;
    struct Node* tail = NULL;
    for(int i = 0; i < n; i++){
        int roll;
        scanf("%d", &roll);
        struct Node* newNode = createNode(roll);
        if(head == NULL)
            head = newNode;
        else
            tail->next = newNode;
        tail = newNode;
    }
    scanf("%d", &toDelete);
    struct Node* temp = head;
    int found = 0;
    while(temp != NULL){
        if(temp->data == toDelete){
            found = 1;
            break;
        }
        temp = temp->next;
    }
    if(!found){
        printf("Not Found");
        return 0;
    }
    head = deleteNode(head, toDelete);
    printList(head);
    return 0;
}