#include<stdio.h>
#include<stdlib.h>

typedef struct node{
    int data;
    struct node *next;
}s1;
s1 *head=NULL,*tail=NULL;
void create(int num){
    s1 *new=(s1*)malloc(sizeof(s1));
    new->data=num;
    new->next=NULL;
    if(head==NULL){
        head=new;
        tail=new;
    }else{
        tail->next=new;
        tail=new;
    }
}

int delete(int val,int found){
    s1* first,*second;
    first=head;
    second=head->next;
    if(first->data==val){
        head=head->next;
    }else{
        while(second!=NULL){
            if(second->data==val){
                first->data=second->data;
            }
            first=first->next;
            second=second->next;
        }
    }
}

int display(){
    s1 *i;
    for(i=head;i!=NULL;i=i->next){
        printf("%d ",i->data);
    }
}

int main(){
    int size,val,num;
    int found=0;
    if(size<0||(!scanf("%d",&size))){
        printf("Node not found");
        return 0;
    }
    for(int i=1;i<=size;i++){
        scanf("%d ",&num);
        create(num);
    }
    scanf("%d",&val);
    delete(val,found);
    if(second==NULL){
        printf("Node not found");
        return 0;
    }
    display();
        
    
}