#include <bits/stdc++.h>
using namespace std;
const int __ = 2e5 + 5;
int a[__];
vector<int> G;
int main() {
  for (int n; ~scanf("%d", &n);) {
    for (int i = (1); i <= (n); ++i) {
      scanf("%d", &a[i]);
      if (!G.empty() && (a[i] & 1) == (G.back() & 1))
        G.pop_back();
      else
        G.push_back(a[i]);
    }
    if (((int)(G).size()) < 2)
      puts("YES");
    else
      puts("NO");
    G.clear();
  }
  return 0;
}
