#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const int INF = 1e9;
const long long mod = 1e9 + 7;
int n, arr[N];
vector<int> v;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    if (v.size() == 0 || v.back() != (arr[i] % 2))
      v.push_back(arr[i] % 2);
    else if (v.size() > 0 && v.back() == (arr[i] % 2))
      v.pop_back();
  }
  if (v.size() <= 1)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
