func_code_string: #include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   using namespace std;   const long long int mod = 1e9 + 7;   const long long int mod1 = 998244353;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   long long int rand(long long int l, long long int r) {     uniform_int_distribution<long long int> uid(l, r);     return uid(rng);   }   const long long int N = 2e5 + 5;   vector<pair<long long int, long long int> > v;   long long int dsu[N], sz[N], a[N];   bool active[N];   long long int odd = 0;   long long int root(long long int u) {     return (dsu[u] == u) ? u : (dsu[u] = root(dsu[u]));   }   long long int n;   void uni(long long int u, long long int v) {     if (u < 1 || u > n) return;     u = root(u), v = root(v);     if (u == v) return;     odd -= (sz[u] & 1);     odd -= (sz[v] & 1);     sz[v] += sz[u];     odd += (sz[v] & 1);     dsu[u] = v;   }   void solve() {     cin >> n;     for (long long int i = 1; i <= n; i++) dsu[i] = i, sz[i] = 1;     for (long long int i = 1; i <= n; i++) cin >> a[i], v.push_back({a[i], i});     sort(v.begin(), v.end());     long long int pt = 0;     while (1) {       long long int val = v[pt].first;       while (pt < n && v[pt].first == val) {         active[v[pt].second] = 1;         odd++;         if (active[v[pt].second - 1]) {           uni(v[pt].second - 1, v[pt].second);         }         if (active[v[pt].second + 1]) {           uni(v[pt].second, v[pt].second + 1);         }         pt++;       }       if (odd && pt != n) {         cout <<  NO  <<   n ;         return;       }       if (pt == n) break;     }     cout <<  YES  <<   n ;   }   signed main() {     ios ::sync_with_stdio(0), cin.tie(0), cout.tie(0);     clock_t clk = clock();     long long int t = 1;     while (t--) {       solve();     }     cerr <<   n  << (double)(clock() - clk) / CLOCKS_PER_SEC;     return 0;   }   