#include <bits/stdc++.h>
using namespace std;
deque<int> q;
int main() {
  int n;
  cin >> n;
  int a;
  for (int i = 0; i < n; i++) {
    cin >> a;
    a %= 2;
    if (q.empty())
      q.push_front(a);
    else {
      if (a != q.front()) {
        q.push_front(a);
      } else if (a == q.front()) {
        q.pop_front();
      }
    }
  }
  if (q.size() > 1)
    cout << "NO\n";
  else
    cout << "YES\n";
}
