#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));
   new Node->data = value;
   new Node->next = NULL;
   return newNode;
}
struct Node* deleteNode(struct Node* head, int x) {
    struct Node *temp =head,*prev =NULL;
    if(temp !=NULL && temp->data ==x) {
        head=temp->next;
        free(temp);
        return head;
    }
    while (temp != NULL && temp->data != x) {
        prev = temp;
        temp = temp->next;
    }
    if(temp == NULL) {
        printf("Node not found ");
        return head;
    }
    pre->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*head = NULL, *temp = NULL;
    for(int i = 0;i < n; i++);{
    scanf("%d", &value);
    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;
}