#include <bits/stdc++.h>
int main() {
  int arr[50], flag = 0;
  int t;
  scanf("%d", &t);
  for (int j = 0; j < t; j++) {
    scanf("%d", &arr[j]);
  }
  int diff[t - 1];
  for (int i = 0; i < (t - 1); i++) {
    diff[i] = abs(arr[i] - arr[i + 1]);
  }
  for (int i = 0; i < (t - 1); i++) {
    int n = diff[i];
    if (n == diff[i + 1])
      flag++;
    else
      break;
  }
  if (flag == (t - 2))
    printf("Yes\n");
  else
    printf("No\n");
}
