#include <bits/stdc++.h>
using namespace std;
int a[200005];
int n, i = 0, k = 0, j, cmp, flg = 0, o = 0, l;
int main() {
  cin >> n;
  for (i = 0; i < n; i++) cin >> a[i];
  cmp = a[0];
  for (i = 0, l = 0; i < n - 1; i++) {
    if (l < 0) {
      a[0] = a[i + 1];
      ++l;
    } else if (a[l] % 2 != a[i + 1] % 2) {
      a[++l] = a[i + 1];
    } else if (abs(a[l] - a[i + 1]) % 2 == 0) {
      --l;
      continue;
    } else if (abs(a[i] - a[i + 1]) % 2 == 1) {
      a[++l] = a[i + 1];
      continue;
    }
  }
  if (l <= 0)
    cout << "YES";
  else {
    cout << "NO";
  }
}
