#include <bits/stdc++.h>
using namespace std;
int n, a[22222222];
int main() {
  stack<int> s;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (s.empty())
      s.push(a[i]);
    else {
      if (s.top() % 2 == a[i] % 2)
        s.pop();
      else
        s.push(a[i]);
    }
  }
  if (s.size() < 2)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
