#include <bits/stdc++.h>
using namespace std;
int n;
int a[200005];
stack<int> b;
int main() {
  scanf("%d", &n);
  for (int i = (0); i < (n); i++) scanf("%d", a + i);
  for (int i = (0); i < (n); i++) {
    int x = a[i];
    if (!b.empty() && x % 2 == b.top() % 2)
      b.pop();
    else
      b.push(x);
  }
  if (b.size() < 2)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
