#include <bits/stdc++.h>
using namespace std;
int n;
int a[200005];
stack<int> S;
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] &= 1;
  }
  for (int i = 1; i <= n; i++) {
    if (S.empty() || S.top() != a[i])
      S.push(a[i]);
    else
      S.pop();
  }
  if (S.size() <= 1)
    cout << "YES";
  else {
    cout << "NO";
  }
  return 0;
}
