#include <bits/stdc++.h>
using namespace std;
char *p1, *p2, buf[100000];
int rd() {
  int x = 0, f = 1;
  char c =
      (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
           ? EOF
           : *p1++);
  while (c < 48) {
    if (c == '-') f = -1;
    c = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++);
  }
  while (c > 47)
    x = (((x << 2) + x) << 1) + (c ^ 48),
    c = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++);
  return x * f;
}
int a[200010];
int q[200010], top;
int main() {
  int n = rd();
  for (int i = 1; i <= n; i++) a[i] = rd() & 1;
  for (int i = 1; i <= n; i++) {
    if (top && (q[top] == a[i]))
      top--;
    else
      q[++top] = a[i];
  }
  if (top > 1)
    puts("NO");
  else
    puts("YES");
  return 0;
}
