#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void ZZ(const char* name, Arg1&& arg1) {
  std::cerr << name << " = " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void ZZ(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  std::cerr.write(names, comma - names) << " = " << arg1;
  ZZ(comma, args...);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  string ans = "NO\n";
  stack<int> st;
  for (int i = 0; i < n; i++) {
    v[i] = v[i] % 2;
    if (!st.empty()) {
      if (st.top() == v[i])
        st.pop();
      else
        st.push(v[i]);
    } else
      st.push(v[i]);
  }
  if (st.size() <= 1) ans = "YES\n";
  cout << ans;
  return 0;
}
