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