func_code_string: #include <bits/stdc++.h>   using namespace std;   const int OO = (int)1e9 + 7;   const int mod = (int)1e9 + 7;   const int MAX = (int)1e5 + 5;   int main(void) {     ios_base::sync_with_stdio(false);     int n;     while (cin >> n) {       vector<pair<int, int> > h;       for (int i = 0; i < n; i++) {         int cur;         cin >> cur;         h.push_back(make_pair(cur, i));       }       sort(h.begin(), h.end());       set<pair<int, int> > s;       for (int i = 0; i < n; i++) {         int l = min(i, h[i].second), r = max(i, h[i].second);         auto it = s.lower_bound(make_pair(l, -1));         if (it == s.end()) {           s.insert(make_pair(r, l));         } else {           int cl = it->second, cr = it->first;           if (r > cl) {             s.erase(it);             s.insert(make_pair(max(cr, r), min(cl, l)));           } else {             s.insert(make_pair(r, l));           }         }       }       int seg = s.size(), tot = 0;       for (auto it = s.begin(); it != s.end(); it++) {         tot += it->first - it->second + 1;       }       cout << seg + (n - tot) <<   n ;     }     return 0;   }   