#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 6;
stack<int> s;
int a[MAX];
int n;
int main() {
  int temp = -1;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] = a[i] % 2;
  }
  for (int i = 1; i <= n; i++) {
    if (s.size() == 0) {
      temp = -1;
    }
    if (s.size() > 0) {
      temp = s.top();
    }
    s.push(a[i]);
    if (s.top() == temp) {
      s.pop();
      s.pop();
    }
  }
  if (s.size() <= 1)
    cout << "YES";
  else
    cout << "NO";
}
