#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
long double eps = 1e-12;
long long dx[] = {0, 0, 1, -1};
long long dy[] = {1, -1, 0, 0};
long long n, res = 0, k = 0, h, ans = 0;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long x, long long y) { return (x * y) / gcd(x, y); }
string s2, ch = "", s, s1 = "", t;
vector<pair<string, long long> > vm;
vector<pair<pair<long long, long long>, long long> > vvvl, vvvr;
vector<pair<long long, long long> > vv, vv2;
vector<long long> v[500005];
long long a[200005];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long i = 0, x = 0, z = 0, y = 0, j = 0, q, mx = 0, mm, idx = 0, ok = 0,
            l = 0, r = 0, negatif = 0, positif = 0, l1, r1, g = 0, d;
  set<pair<long long, long long> >::iterator it, it1, it2;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] %= 2;
  }
  set<pair<long long, long long> > even, segment;
  for (i = 1; i <= n; i++) {
    long long cnt = 0;
    for (j = i; j <= n; j++) {
      if (a[j] != a[i]) break;
      cnt++;
    }
    if (!(cnt & 1)) even.insert({i, j - 1});
    segment.insert({i, j - 1});
    if (j > i) i = j - 1;
  }
  while (segment.size() > 1 && even.size()) {
    it = even.begin();
    l = (*it).first;
    r = (*it).second;
    even.erase(it);
    it = segment.find({l, r});
    it1 = it;
    it2 = it;
    long long l1 = -1, r1;
    if (it1 != segment.begin()) {
      it1--;
      l1 = (*it1).first;
      r1 = (*it1).second;
      l = min(l, l1);
    }
    it2++;
    long long l2 = -1, r2;
    if (it2 != segment.end()) {
      l2 = (*it2).first;
      r2 = (*it2).second;
      r = max(r, r2);
    }
    segment.erase(it);
    if (l1 != -1) {
      segment.erase(it1);
      if (!((r1 - l1 + 1) & 1)) {
        even.erase(even.find({l1, r1}));
      }
    }
    if (l2 != -1) {
      segment.erase(it2);
      if (!((r2 - l2 + 1) & 1)) {
        even.erase(even.find({l2, r2}));
      }
    }
    segment.insert({l, r});
    if (!((r - l + 1) & 1)) even.insert({l, r});
  }
  if (segment.size() > 1) return cout << "NO", 0;
  cout << "YES";
  return 0;
}
