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