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