#include<stdio.h>
#include<stdlib.h>
typedef struct node
{
    int data;
    struct node *next;
    struct node *prev;
}Node;
Node *head=NULL,*tail;
void create(int num)
{
    Node *newnode=(Node*)malloc(sizeof(Node));
    newnode->data=num;
    newnode->next=NULL;
    newnode->prev=NULL;
    if(head==NULL)
    {
        head=newnode;
        tail=newnode;
    }
    else
    {
        tail->next=newnode;
        newnode->prev=tail;
        tail=newnode;
    }
}
void delete(int k)
{
    Node *first=head;
    Node *second=head->next;
    
    while(1)
    {
        if(second->data==k)
        {
           second->next->prev=first->next;
           first->next=second->prev;
           break;
        } 
        first=first->next;
        second=second->next;
       
    }
}
void display()
{
    Node *itr;
    for(itr=head;itr!=NULL;itr=itr->next)
       printf("%d ",itr->data);
}
int main()
{
    int n,x,num,itr;
    scanf("%d",&n);
    for(itr=0;itr<n;itr++)
    {
        if(!(scanf("%d",&num)))
        {
            printf("Node not found");
            return 0;
        }
        create(num);
    }
    delete(k);
    display();
    return 0;
}