#include <bits/stdc++.h>
using namespace std;
int n, a[200005], top, stk[200005], s;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    s = max(s, a[i]);
  }
  a[n + 1] = 2000000000;
  for (int i = 1; i <= n; i++) {
    if (top != 0 && abs(stk[top] - a[i]) % 2 == 0)
      top--;
    else {
      top++;
      stk[top] = a[i];
    }
  }
  for (int i = 2; i <= top; i++)
    if ((stk[i] - stk[i - 1]) % 2 != 0) {
      cout << "NO";
      return (0);
    }
  cout << "YES";
}
