#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const double EPS = 1e-10;
const double PI = acos(-1);
class D1GreatVovaWallVersion1 {
 public:
  void solve(std::istream& in, std::ostream& out) {
    ios_base::sync_with_stdio(false);
    in.tie(nullptr), out.tie(nullptr);
    int N;
    in >> N;
    vector<int> A(N);
    for (int i = (0); i < (N); ++i) in >> A[i], A[i] %= 2;
    stack<int> st;
    st.push(A[0]);
    for (int i = (1); i < (N - 1 + 1); ++i) {
      if (not st.empty() and A[i] == st.top()) {
        st.pop();
      } else {
        st.push(A[i]);
      }
    }
    if ((int)(st).size() > 1)
      out << "NO\n";
    else
      out << "YES\n";
  }
};
int main() {
  D1GreatVovaWallVersion1 solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}
