#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  stack<int> s;
  int temp;
  for (int i = 0, _i = (n); i < _i; ++i) {
    cin >> temp;
    temp = temp % 2;
    if (s.empty() || s.top() != temp)
      s.push(temp);
    else
      s.pop();
  }
  if (s.size() > 1)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
}
