#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int a[n];
  stack<int> COC;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    a[i] %= 2;
    if (!COC.empty() && COC.top() == a[i])
      COC.pop();
    else
      COC.push(a[i]);
  }
  if (COC.size() <= 1) {
    cout << "YES" << '\n';
    return 0;
  } else {
    cout << "NO" << '\n';
  }
  return 0;
}
