#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, h;
  scanf("%d", &n);
  stack<int> stk;
  scanf("%d", &h);
  stk.push(h);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &h);
    if (stk.size() && (h - stk.top()) % 2 == 0)
      stk.pop();
    else
      stk.push(h);
  }
  if (stk.size() <= 1)
    printf("YES\n");
  else
    printf("NO\n");
}
