#include<stdio.h>
#include<stdlib.h>

typedef struct node{
    int data;
    struct node*next;
}Node;

Node *head=NULL ,*tail;


void deletion(int val){
    
    if(head == NULL){
        printf("list is empty");
        return;
    }
    
    Node *first = head;
    Node *second = head->next;
    
    if(head->data==val){
        head = head->next;
        free(first);
        return;
    }
    else{
        while(second!=NULL){
            if(second->data==val){
                first->next=second->next;
                free(second);
                return;
                
            }
            first=first->next;
            second=second->next;
            
        }
       
    }
    printf("Node found");
    return 0;
}
void create(int num){
    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;
    }
}

void display(){
    Node *itr=head;
    while(itr!=NULL){
        printf("%d ",itr->data);
        itr=itr->next;
        
    }
}

int main(){
    int size,num,val,i;
    scanf("%d" ,&size);
    for(int itr=0;itr<size;itr++){
        scanf("%d",&num);
        create(num);
    }
    
    scanf("%d",&val);
 
    deletion(val);
    display();
    
    return 0;
}