#include <bits/stdc++.h>
using namespace std;
namespace flyinthesky {
int n, a[200000 + 5], top, st[200000 + 5];
void clean() { top = 0; }
int solve() {
  clean();
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 1; i <= n; ++i) {
    if (!top)
      st[++top] = a[i];
    else {
      if ((st[top] - a[i]) % 2 == 0)
        --top;
      else
        st[++top] = a[i];
    }
  }
  if (top <= 1)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
}  // namespace flyinthesky
int main() {
  flyinthesky::solve();
  return 0;
}
