#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("O3", "omit-frame-pointer", "inline")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
using namespace std;
const long long mod = 998244353;
mt19937 rng((int)chrono::steady_clock::now().time_since_epoch().count());
const int mxN = 5010;
int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  srand(time(NULL));
  cout << fixed << setprecision(9);
  int t = 1;
  while (t--) {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<int> e;
    for (int i = 0; i < n; i++) {
      if (!e.empty() && e.back() % 2 == a[i] % 2)
        e.pop_back();
      else
        e.push_back(a[i]);
    }
    cout << (e.size() <= 1 ? "YES" : "NO") << '\n';
  }
  return 0;
}
