// editor5
#include<stdio.h>
#include<stdlib.h>

typedef struct dbly
{
    int data;
    struct dbly *prev,*next;
}node;

node *head=NULL,*tail=NULL;
void create(int n)
{
    node*nd=(node*)malloc(sizeof(node));
    nd->data=n;
    nd->prev=nd->next=NULL;
    if(head==NULL)
    {
        head=tail=nd;
    }
    else
    {
        nd->next=head;
        head->prev=nd;
        head=nd;
    }
}

void traverse()
{
    node *temp=head,*temp2=tail;
    while(temp!=temp2)
    {
        if(temp->data!=temp2->data)
        {
            printf("No");
            return;
        }
        temp=temp->next;
        temp2=temp2->prev;
    }
    printf("Yes");
}

int main()
{
    int n;
    while(1)
    {
        scanf("%d",&n);
        if(n<0)
        {
            if(n==-1)
            {
                break;
            }
            else{
                printf("Invalid input");
                return 0;
            }
        }
        else
        {
           create(n); 
        }
        
    }
    traverse();
}