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