#include <bits/stdc++.h>
using namespace std;
bool comp(int a, int b) { return a < b; }
int main() {
  stack<int> s;
  int N, t;
  cin >> N;
  while (N--) {
    cin >> t;
    if (s.empty()) {
      s.push(t);
    } else {
      if (((s.top()) & 1) == (t & 1))
        s.pop();
      else
        s.push(t);
    }
  }
  if (s.size() < 2)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
