#include <bits/stdc++.h>
using namespace std;
const int N = 200 * 1000 + 13;
int n;
int a[N];
int main() {
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] &= 1;
  }
  vector<int> st;
  for (int i = 0; i < n; i++) {
    if (!st.empty() && a[i] == st.back())
      st.pop_back();
    else
      st.push_back(a[i]);
  }
  cout << ((int)st.size() <= 1 ? "YES" : "NO") << endl;
  return 0;
}
