#include <bits/stdc++.h>
using namespace std;
int main() {
  int str[100000 + 10];
  int t, pointer = 0;
  cin >> t;
  for (int i = 0; i < t; i++) {
    cin >> str[pointer];
    str[pointer] = str[pointer] % 2;
    while (pointer >= 1 && str[pointer] == str[pointer - 1]) pointer -= 2;
    pointer++;
  }
  if (pointer <= 1)
    cout << "YES";
  else
    cout << "NO";
}
