#include <bits/stdc++.h>
using namespace std;
stack<int> stk;
int main() {
  int n;
  scanf("%d", &n);
  while (n--) {
    int x;
    scanf("%d", &x);
    if (stk.size() && x % 2 == stk.top())
      stk.pop();
    else
      stk.push(x % 2);
  }
  if (stk.size() > 1)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
  return 0;
}
