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