#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
const int INF32 = 0x3f3f3f3f;
const long long INF64 = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;
const double PI = acos(-1.0);
stack<int> st;
int main() {
  int n;
  while (cin >> n) {
    while (st.size()) st.pop();
    int h;
    for (int i = 1; i <= n; ++i) {
      cin >> h;
      if (st.size() == 0)
        st.push(h);
      else {
        if (st.top() % 2 == h % 2) {
          st.pop();
        } else
          st.push(h);
      }
    }
    if (st.size() <= 1)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
