#include<stdio.h>
#include<stdlib.h>
 struct { 
     int data;
     Struct Node*next;
 };
int main(){
    int n,x,val;
    struct Node*head=NULL,*tail=NULL;
    struct Node*curr,*prev;
    struct Node*first=NULL*firstPrev=NULL;
    struct Node*last=NULL,*lastPrev=NULL;
    scanf("%d",&n);
      
      if(n<=0){
          print("Invalid input"):
          return 0;
      }
      for (int i=0;i<n,i++){
          scanf("%d",&val);
          struct Node temp=(struct node)malloc(size of(struct Node));
          temp->data=val;
          temp->next=NULL;
          
          if(head==NULL)
           head =tail=temp;
           else{
               tail->next=temp;
               tail=temp;
           }
      }
      scanf("%d",&x);
      
      curr=head;
      prev=NULL;
       while(curr!=NULL){
           if(curr->data==x){
               if(first==NULL){
                   first=curr;
                   firstPrev=prev;
               }
               last=curr
               lastPrev=prev;
           }
           prev=curr;
           curr=curr->next;
       }
       if (first==NULL){
           print("Element not found");
           return 0;
       }
       if (firstPrev==NULL)
           head=first->next;
           else
             firstPrev->next=first->next;
             
        if (last!=first){
            if(lastPrev==NULL)
            head=last->next;
            else
             lastPrev->next=last->next;
        }
        curr = head;
        while (curr!=NULL){
            printf("%d",curr->data);
            curr=curr->next;
        }
        return 0;
}