func_code_string: #include <bits/stdc++.h>   using namespace std;   using ull = unsigned long long;   using ll = long long;   using ld = long double;   using ii = pair<int, int>;   using vi = vector<int>;   template <class T>   T abs(T x) {     return x > 0 ? x : -x;   }   int main() {     ios_base::sync_with_stdio(false);     int n;     cin >> n;     vector<pair<int, int>> v(n);     int cur;     for (int i = 0; i < n; ++i) {       cin >> cur;       v[i] = make_pair(cur, i + 1);     }     sort(v.begin() + 1, v.end(), greater<pair<int, int>>());     queue<int> q;     vector<char> ch(n, false);     ch[0] = true;     q.push(0);     int pos = 1;     vector<pair<int, int>> ans;     while (!q.empty()) {       cur = q.front();       for (int i = 0; i < v[cur].first; ++i)         if (pos < n) {           q.push(pos);           ans.push_back(make_pair(v[cur].second, v[pos].second));           ++pos;         }       q.pop();     }     if (pos != n)       cout << -1 << endl;     else {       cout << ans.size() << endl;       for (int i = 0; i < ans.size(); ++i)         cout << ans[i].first <<     << ans[i].second << endl;     }     return 0;   }   