#include <bits/stdc++.h>
using namespace std;
int main() {
  stack<int> a;
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int m;
    cin >> m;
    if (a.empty() == true) {
      a.push(m);
    } else {
      if ((a.top() - m) % 2 == 0) {
        a.pop();
      } else {
        a.push(m);
      }
    }
  }
  if (a.size() > 1)
    cout << "NO";
  else
    cout << "YES";
}
