#include <bits/stdc++.h>
using namespace std;
const int N = (int)2e5 + 15;
const int inf = 0x3f3f3f3f;
int a[N];
int main() {
  int n;
  while (~scanf("%d", &n)) {
    stack<int> stk;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      a[i] &= 1;
      if (!stk.empty() && stk.top() == a[i]) {
        stk.pop();
      } else {
        stk.emplace(a[i]);
      }
    }
    puts(stk.size() <= 1 ? "YES" : "NO");
  }
}
