// editor4
#include<stdio.h>
#include<stdlib.h>
typedef struct node{
    int data;
    struct node *next;
}nd;
nd *head=NULL,*tail;
void create(int num){
    nd *newnode=(nd*)malloc(1*sizeof(nd));
    newnode->data=num;
    newnode->next=NULL;
    if(head==NULL){
        newnode=head;
        newnode=tail;
    }
    else{
        tail->next=newnode;
        tail=newnode;
    }
}
nd *first,*second;
void deleteVal(int val){
    first=head;
    second=head->next;
    if(head->data==val){
        first->next=second->next;
        // break;
    }
    else{
        while(second!=NULL){
            if(second->data==val){
               first=first->next;
               second=second->next;
            }
        }
    }
    int main(){
        int n,num,val,itr;
        scanf("%d",&n);
        
        for(itr=0;itr<n;itr++){
            scanf("%d",&num);
            
            create(num);
        }
        scanf("%d",&val);
        deleteVal(val);
    }
}