func_code_string: #include <bits/stdc++.h>   using namespace std;   using ll = long long;   vector<pair<int, int>> ans;   int main() {     cin.tie(0);     ios::sync_with_stdio(false);     int n;     cin >> n;     vector<int> a(n);     for (int i = 0; i < n; i++) cin >> a[i];     reverse(a.begin(), a.end());     vector<pair<int, int>> ans;     int m = a[0] + 1;     vector<int> cnt(m);     int l = 0, r = n;     int st = 0;     int en = m;     while (l < r) {       if (cnt[en - 1] == a[r - 1]) {         --en;         --r;         continue;       }       if (a[l] >= en) l++;       for (int i = 0; i < a[l] - st; i++) {         ans.emplace_back(st, st + i + 1);         cnt[st]++;         cnt[st + i + 1]++;       }       en = a[l] + 1;       st++;     }     cout << ans.size() << endl;     for (auto p : ans) cout << p.first + 1 <<     << p.second + 1 << endl;   }   