#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 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)
    return head;
    prev->next=temp->next;
    free(temp);
    return head;
}
void printList(struct Node*head){
    if(head==NULL){
        printf("Node not found");
        return;
    }
    struct Node*temp=head;
    while(temp!=NULL){
        printf("%d",temp->data);
        if(temp->next!=NULL)
        printf(" ");
        temp=temp->next;
    }
}
int main(){
    int n,x,i,val;
    scanf("%d",&n);
    struct Node*head=NULL,*tail=NULL;
    for(i=0;i<n;i++){
        scanf("%d",&val);
        struct NOde*newNode=createNode(val);
        if(head==NULL)
        head=tail=newNode;
        else{
            tail->next=newNode;
            tail=newNode;
        }
    }
    scanf("%d",&x);
    struct Node*temp=head;
    int found=0;
    while(temp!=NULL){
        if(temp->data==x){
            found=1;
            break;
        }
        temp=temp->next;
    }
    if(!found){
        printf("Node not found");
        return 0;
    }
    head=deleteNode(head,x);
    printList(head);
    return 0;
}