#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  long long i, a[n + 1];
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] = a[i] % 2;
  }
  vector<long long> s;
  for (i = 1; i <= n; i++) {
    if (s.empty() || s.back() != a[i]) {
      s.push_back(a[i]);
    } else {
      s.pop_back();
    }
  }
  if (s.size() > 1)
    cout << "NO";
  else
    cout << "YES";
}
