#include<stdio.h>
#include<stdlib.h>

typedef struct node{
    int data;
    struct node *next;
    
}Node;

Node *head=NULL,*tail,*prev;
void create(int num){
    Node *newNode=(Node*)malloc(sizeof(Node));
    newNode->data=num;
    newNode->next=NULL;
    
    if(head==NULL){
        head= newNode;
        tail= newNode;
    }
    else{
        tail->next= newNode;
        tail= newNode;
    }
}

void delete(int element){
    Node *temp ,*prev;
      int count=0;
     temp=head;
     
     
     if(head->data=element){
         temp=head;
         head=head->next;
         free(temp);
     }
     while(temp!=NULL && temp->data!=element){
         prev=temp;
         temp=temp->next;
     }
      
        prev->next=temp->next;
        
        if(temp==NULL){
            printf("List is empty");
        }
         free(temp);
}

void display(){
    Node *i=head;
     while(i->next!=NULL){
        printf("%d",i->data);
         i=i->next;
}


int main(){
    int n,val,e;
    scanf("%d",&n);
    for(int i=0 ; i<n ;i++){
        scanf("%d",&val);
        create(val);
    }
    scanf("%d",&e);
    delete(e);
    display();
    
    
    return 0;
}