#include <bits/stdc++.h>   const double g = 9.8;   using namespace std;   const long long mod = 998244353;   long long quick(long long prea, long long bbb) {     long long res = 1;     while (bbb) {       if (bbb & 1) res = res * prea % mod;       prea = prea * prea % mod;       bbb >>= 1;     }     return res;   }   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   pair<int, int> pp;   const int w = 2e5 + 5;   long long a[w];   stack<long long> s;   int main() {     long long k, m, n, t, i, j;     cin >> n;     for (i = 0; i < n; i++) {       cin >> m;       if (s.empty())         s.push(m);       else {         if (abs(m - s.top()) % 2 == 0)           s.pop();         else           s.push(m);       }     }     if (s.size() > 1)       cout <<  NO  << endl;     else       cout <<  YES  << endl;     return 0;   }   