#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  for (int i = 0; i < n; ++i) {
    cin >> A[i];
    if (A[i] % 2 == 0) {
      A[i] = 0;
    } else {
      A[i] = 1;
    }
  }
  vector<int> CHECK;
  for (int i = 0; i < n; ++i) {
    if (!CHECK.empty() && A[i] == CHECK.back()) {
      CHECK.pop_back();
    } else {
      CHECK.push_back(A[i]);
    }
  }
  if (CHECK.size() <= 1) {
    cout << "YES" << endl;
    return 0;
  }
  cout << "NO" << endl;
  return 0;
}
