#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, h;
  cin >> n;
  stack<long long> q;
  cin >> h;
  q.push(h);
  for (int i = 2; i <= n; i++) {
    cin >> h;
    if (!q.empty()) {
      if (q.top() == h || (abs(q.top() - h) % 2) == 0) {
        q.pop();
      } else {
        q.push(h);
      }
    } else {
      q.push(h);
    }
  }
  if (q.size() <= 1) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
