#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> d(n);
  vector<vector<pair<int, int> > > v(n);
  for (int i = 0; i < n; i++) {
    cin >> d[i];
    v[d[i]].push_back(make_pair(i + 1, k));
  }
  vector<vector<int> > g(n + 1);
  if ((int)v[0].size() != 1) {
    cout << -1;
    return 0;
  }
  int ind = 0;
  int ans = 0;
  for (int i = 1; i < n; i++) {
    for (int k = 0; k < (int)v[i].size(); k++) {
      ind = 0;
      if (v[i][k].second == 0) continue;
      for (int j = 0; j < (int)v[i - 1].size(); j++) {
        if (v[i - 1][j].second > 0) {
          ind = 1;
          v[i - 1][j].second--;
          g[v[i - 1][j].first].push_back(v[i][k].first);
          v[i][k].second--;
          ans++;
          break;
        }
      }
      if (ind == 0) {
        cout << -1;
        return 0;
      }
    }
  }
  printf("%d\n", ans);
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < (int)g[i].size(); j++) printf("%d %d\n", i, g[i][j]);
  }
}
