#include <bits/stdc++.h>
using namespace std;
const int N = 200 * 1000 + 13;
int n, a[N];
int main() {
  stack<int> s;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (!s.empty() && abs(s.top() - a[i]) % 2 == 0)
      s.pop();
    else
      s.push(a[i]);
  }
  if (s.size() <= 1)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
