// editor2
#include<stdio.h>
#include<stdlib.h>

typedef struct node{
    int data;
    struct node*next;
}Node;

Node*head=NULL,*tail;

int deletion(int val){
    
    if(head==NULL){
        printf("List is Empty");
        return 1;
    }
    Node *first=head;
    Node *second=head->next;
    
    if(head->data == val){
        head=head->next;
        free(first);
        return 1;
    }
    else{
        while(second!=NULL){
            if(second->data == val){
                first->next=second->next;
                free(second);
                return 1;
            }
            
            first=first->next;
            second=second->next;
            
        }
       // first=first->next;
        //second=second->next;
    // printf("Node not found\n");
        
   
    }
     printf("Node not found");
        return 0;
    
}

    


void create(int num){
    int val;
    Node*newNode = (Node*)malloc(1*sizeof(newNode));
    newNode->data=num;
    newNode->next=NULL;
    
    if(head==NULL){
        head=newNode;
        tail=newNode;
    }
    else{
        tail->next=newNode;
        tail = newNode;
    }
   // printf("%d ",num);
}
void display(){
    Node*itr=head;
    while(itr != NULL){
        printf("%d ",itr->data);
        itr = itr->next;
        return 0;
        ////if(itr != NULL){
            //printf("  ");
        //}
        
    }
   // 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");
              
          //}
        deletion(val);
        display();
        return 0;
    }