#include <bits/stdc++.h>
using namespace std;
struct dt {
  int id, dis;
  bool operator<(const dt& rhs) const { return dis > rhs.dis; }
};
vector<int> V[100005];
priority_queue<dt> Q;
priority_queue<dt> D[100005];
int main() {
  int i, j, k, l, m, n, I, J, d, root;
  cin >> n >> k;
  int cnt = 0;
  for (i = 0; i < n; i++) {
    cin >> d;
    if (d == 0) cnt++;
    Q.push({i, d});
  }
  if (cnt != 1) {
    cout << -1;
    return 0;
  }
  root = Q.top().id;
  Q.pop();
  D[0].push({root, 0});
  bool f = false;
  while (!Q.empty()) {
    auto x = Q.top();
    Q.pop();
    d = x.dis - 1;
    if (D[d].empty()) {
      f = true;
      break;
    }
    auto y = D[d].top();
    D[d].pop();
    int sz = V[y.id].size();
    int ex = (d != 0);
    if (sz + ex + 1 > k) {
      f = true;
      break;
    }
    V[y.id].push_back(x.id);
    D[d].push({y.id, int(V[y.id].size())});
    D[x.dis].push({x.id, 0});
  }
  if (f) {
    cout << -1;
    return 0;
  }
  int sum = 0;
  for (i = 0; i < n; i++) {
    sum += V[i].size();
  }
  cout << sum << endl;
  for (i = 0; i < n; i++) {
    for (auto x : V[i]) cout << i + 1 << " " << x + 1 << endl;
  }
  return 0;
}
