func_code_string: #include <bits/stdc++.h>   using namespace std;   mt19937 rnd(51);   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     long long n;     cin >> n;     vector<long long> a(n);     for (long long i = 0; i < n; i++) {       cin >> a[i];     }     deque<pair<long long, long long>> q;     for (long long i = 0; i < n; i++) {       if (q.size() == 0) {         q.push_back({a[i], 1});       } else {         if (q.back().first == a[i]) {           q.back().second++;           if (q.size() > 1 && q[q.size() - 2].first >= q.back().first) {             long long now = q.back().second;             q.pop_back();             q.back().second += now;           }         } else if (q.back().first > a[i]) {           q.push_back({a[i], 1});         } else {           if (q.back().second % 2 == 1) {             cout <<  NO n ;             return 0;           } else {             q.push_back({a[i], 1});           }         }       }     }     while (q.size() > 1 && ((q[q.size() - 2].second % 2 == 0 &&                              q[q.size() - 2].first < q.back().first) ||                             (q.back().second % 2 == 0 &&                              q.back().first < q[q.size() - 2].first))) {       long long now = q.back().second;       long long mx = max(q.back().first, q[q.size() - 2].first);       q.pop_back();       q.back().first = mx;       q.back().second += now;     }     if (q.size() == 1) {       cout <<  YES n ;     } else {       cout <<  NO n ;     }     return 0;   }   