#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100090;
struct Ans {
  int x, y;
} ans[MAXN];
int ans_num;
int d[MAXN], degree[MAXN];
int r[MAXN];
int k, n;
int cmp(int i, int j) { return d[i] < d[j]; }
void clear_queue(queue<int> &Q) {
  while (!Q.empty()) Q.pop();
}
queue<int> Q[2];
void solve() {
  memset(degree, 0, sizeof(degree));
  sort(r, r + n, cmp);
  ans_num = 0;
  clear_queue(Q[0]);
  clear_queue(Q[1]);
  Q[0].push(r[0]);
  int qc = 0;
  int now = 0;
  bool flag = true;
  for (int i = 1; i < n && flag; i++) {
    int v = r[i];
    if (d[v] != (now + 1)) {
      clear_queue(Q[qc]);
      qc ^= 1;
      now++;
    }
    if (Q[qc].empty()) {
      flag = false;
      break;
    }
    int u = Q[qc].front();
    Q[qc].pop();
    if ((degree[u] == k) || (d[v] != d[u] + 1)) {
      flag = false;
      break;
    }
    ans[ans_num].x = u;
    ans[ans_num].y = v;
    ans_num++;
    degree[u]++;
    degree[v]++;
    Q[qc].push(u);
    Q[1 ^ qc].push(v);
  }
  if (flag && (ans_num == n - 1)) {
    printf("%d\n", ans_num);
    for (int i = 0; i < ans_num; i++)
      printf("%d %d\n", ans[i].x + 1, 1 + ans[i].y);
  } else {
    printf("-1\n");
  }
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", d + i);
    r[i] = i;
  }
  solve();
  return 0;
}
