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