#include <bits/stdc++.h>   const long double PI(acosl(-1.0));   long double eps = 1e-9;   using namespace std;   using namespace std;   const int N = 1000000;   int main() {     std::ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     vector<pair<int, int> > p(n);     int s = 0;     for (int i(0); i < n; i++) {       int x;       cin >> x;       s += x;       p[i] = {x, i + 1};     }     sort(++p.begin(), p.end());     reverse(++p.begin(), p.end());     vector<pair<int, int> > ans;     int j = 1;     int i = 0;     while (j < n) {       while (j < n && p[i].first > 0) {         ans.push_back({p[i].second, p[j].second});         p[i].first--;         j++;       }       i++;       if (i == j) break;     }     if (j < n) {       cout << -1;       return 0;     }     cout << ans.size() << endl;     for (int i(0); i < ans.size(); i++)       cout << ans[i].first <<     << ans[i].second <<   n ;   }   