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