#include <stdio.h>
#include <stdlib.h>

struct Node {
    int data;
    struct Node* next;
};

struct Node* createNode(int value) {
    struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
    newNode->data = value;
    newNode->next = NULL;
    return newNode;
}

struct Node* deleteNode(struct Node* head, int x) {
    struct Node *temp = head, *prev = NULL;
    if (temp != NULL && temp->data == x) {
        free(temp);
        return head;
    }
    while(temp != NULL && temp->data != x) {
        prev = temp;
        temp = temp->next;
    }
    if (temp == NULL){
        printf("Node not found");
        return head;
    }
    prev->next = temp->next;
    free(temp);
    return head;
}
void printList(struct Node* node){
    while (node != NULL) {
        printf("%d", node->data);
        if (node->next != NULL)
            printf(" ");
        node =  node->next;
    }
}
int main(){
    int n, x, value;
    scanf("%d", &n);
    struct Node *headNULL,* temp =NULL;
    for (int i = 0; i < n; i++) {
        struct Node* newNode = createNode(value);
        if ( head == NULL)
            head = newNode;
        else
            temp->next = newNode;
            temp = newNode;
    }
    scanf("%d", &x);
    struct Node* check = head;
    int found = 0;
    while (check != NULL) {
        if (check->data == x) {
            found = 1;
            break;
        }
        check = check->next;
    }
    if (!found) {
        printf("Node not found");
        return 0;
    }
    head = deleteNode(head, x);
    printList(head);
    return 0;
}