/*Given a sequence of N integers. Find whether it is an Arithmetic sequence or not. An arithmetic sequence is a sequence of numbers where the difference between any two consecutive numbers is always the same. For example:

[5, 8, 11, 14] is an arithmetic sequence because the difference between consecutive terms is always +3.
[9, 5, 1, -3] is an arithmetic sequence because the difference between consecutive terms is always -4.
[2, 5, 7, 10] is not an arithmetic sequence because the differences between consecutive terms are +3, +2, +3.
[3, 6, 3] is not an arithmetic sequence because the differences between consecutive terms are +3, -3.
Input Format

One integer N, the size of the sequence. Followed by N integer numbers, aka the sequence.

Constraints


Output Format

Print "YES" (without quotation), if the sequence is an arithmatic sequence.
Otherwise print "NO" (without quotation).*/

#include<stdio.h>
int main()
{
    int n,i,current,previous,difference;
    int arithmetic=1;
    scanf("%d",&n);
     if(n<2)
      {
        printf("NO\n");
        return 0;
      }
    scanf("%d %d",&previous,&current);
    difference = current-previous;
     for(i=2;i<n;i++)
      {
        previous=current;
        scanf("%d",&current);
        if(current-previous!=difference)
         {
            arithmetic=0;
            
         }


      }
    if(arithmetic)
    {printf("YES\n");}
    else{
        printf("NO\n");
    } 

return 0;
}