// editor2
// editor1
#include<stdio.h>
#include<stdlib.h>
typedef struct node{
    int data;
    struct node*next;
}Node;
Node *head=NULL,*tail,*itr;
void create(int num){
    Node*newNode=(Node*)malloc(1 *sizeof(Node));
    newNode->data=num;
    newNode->next=NULL;
    if(head==NULL){
        head=newNode;
        tail=newNode;
    }
    else{
        tail->next=newNode;
        tail=newNode;
    }
}
void delete(int val){
    itr=head->next;
    if(head->data==val){
        head=head->next;
    }
    else{
        while(itr!=NULL){
            if(itr->data==val){
                itr=itr->next;
                break;
            }
        }
        itr=itr->next;
    }
    
}
void display(){
    Node*i;
    for(i=head;i!=NULL;i=i->next){
        printf("%d ",i->data);
    }
    
}
int main(){
    int size,i,num;
    scanf("%d",&size);
    if(size<0){
        printf("Invalid Input");
        return 0;
    }
    for(i=0;i<size;i++){
        if(!scanf("%d",&num)){
            printf("Invalid Input");
        }
        create(num);
    }
    scanf("%d",&val);
    delete(val);
    if(itr==NULL)
        printf("NOde not found");
    else
        display();
    
       
    
    return 0;
}