#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
const int mod = 1e9 + 7;
inline int bigmod(int B, int P) {
  int R = 1;
  while (P > 0) {
    if (P & 1) {
      R = (R * B) % mod;
    }
    P >>= 1;
    B = (B * B) % mod;
  }
  return R;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int tt = 1;
  for (int tc = 1; tc <= tt; tc++) {
    long long n;
    cin >> n;
    int ip[n];
    for (int i = 0; i < n; i++) {
      cin >> ip[i];
      ip[i] %= 2;
    }
    vector<int> chck;
    for (int i = 0; i < n; i++) {
      if (!chck.empty() && ip[i] == chck.back()) {
        chck.pop_back();
      } else
        chck.push_back(ip[i]);
    }
    if (chck.size() <= 1)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
