#include <stdio.h>
#include <stdlib.h>

typedef struct Node {
    int date;
    struct Node* next;
}Node;

Node* createNode(int data) {
    Node* newNode = (Node*)malloc(sizeof(Node));
    newNode->date = data;
    newNode->next = NULL;
    return newNode;
}

Node* deleteNode(Node* head, int toDelete) {
    Node* temp = head;
    Node* prev = NULL;
    
    if (head == NULL)
        return NULL;
        
    if (temp != NULL && temp->date == toDelete) {
        head = temp->next;
        free(temp);
        return head;
    }
    while (temp != NULL && temp->date != toDelete) {
        prev = temp;
        temp = temp->next;
    }
    if (temp == NULL)
        return head;
        
    prev->next = temp->next;
    free (temp);
    
    return head;
}

void printList(Node* head) {
    if (head == NULL) {
        printf("List is empty");
        return;
    }
    Node* temp = head;
    while (temp != NULL) {
        printf("%d", temp->date);
        if (temp->next != NULL)
            printf(" ");
        temp = temp->next;
    }
}
int main(){
    int n, i, val, toDelate;
    scanf("%d", &n);
    
    Node* head = NULL;
    Node* tail = NULL;
    
    for (i = 0; i < n; i++) {
        scanf("%d", &val);
        Node* newNode = createNode(val);
        if (head == NULL) {
            head == newNode;
            tail == newNode;
        } else {
            tail->next = newNode;
            tail == newNode;
        }
    }
    
    scanf("%d", &toDelate);
    
    Node* temp = head;
    int found = 0;
    while (temp != NULL) {
        if (temp->date == toDelate) {
            found = 1;
            break;
        }
        temp = temp->next;
    }
    
    if (!=found) {
        printf("Not found");
        return 0;
    }
    
    head = deleteNode(head, toDelete);
    printList(head);
    
    return 0;
}