func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long maxn = 3e5 + 7, mod = 998244353, inf = 1e18, MAXN = 1e6 + 7;   const double eps = 1e-9;   mt19937 rnd(time(0));   long long n;   long long cnt[maxn];   struct state {     long long a, b, d;     state(long long a, long long b, long long d) : a(a), b(b), d(d) {}     state() : a(0), b(0), d(0) {}   };   vector<state> have;   bool cmp(state p1, state p2) { return p1.d > p2.d; }   vector<long long> gr[maxn];   vector<long long> step[maxn];   void solve() {     cin >> n;     for (long long i = 1; i <= n; ++i) {       long long d;       cin >> d;       long long a = 2 * i;       long long b = a - 1;       have.emplace_back(b, a, d);     }     sort(have.begin(), have.end(), cmp);     vector<long long> even;     for (auto v : have) {       even.push_back(v.a);     }     for (long long i = 1; i < n; ++i) {       gr[even[i - 1]].push_back(even[i]);     }     long long size = n;     for (long long i = 0; i < n; ++i) {       --size;       long long d = have[i].d;       long long b = have[i].b;       if (size < d) {         gr[even.back()].push_back(b);         even.push_back(b);         ++size;       } else {         gr[even[i + d - 1]].push_back(b);       }     }     for (long long i = 1; i <= 2 * n; ++i) {       for (auto v : gr[i]) {         cout << i <<     << v <<   n ;       }     }   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.precision(20);     cout << fixed;     long long t = 1;     for (long long i = 0; i < t; ++i) {       solve();     }     return 0;   }   