#include <bits/stdc++.h>
using namespace std;
const long long N = 200005;
void solve() {
  long long n, x;
  cin >> n;
  stack<long long> s;
  long long mx = 0;
  for (__typeof((n)) i = (1); i <= (n); i++) {
    cin >> x;
    mx = max(mx, x);
    if (s.empty())
      s.push(x);
    else if ((s.top() + x) % 2 == 0)
      s.pop();
    else
      s.push(x);
  }
  if (s.size() >= 2)
    cout << "NO" << '\n';
  else
    cout << "YES" << '\n';
}
signed main() {
  long long t;
  ios_base::sync_with_stdio(false);
  t = 1;
  while (t--) solve();
  return 0;
}
