#include <bits/stdc++.h>
using namespace std;
struct data {
  int sta, n;
} a[100010], p[100010];
struct data2 {
  int p, q;
};
queue<data2> que;
int cmp(data x, data y) { return x.sta < y.sta; }
int main() {
  int n, k, ma = 0;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &p[i].sta);
    ma = max(p[i].sta, ma);
    p[i].n = i;
  }
  sort(p + 1, p + 1 + n, cmp);
  for (int i = 1; i <= n; i++) {
    if (a[p[i].sta].sta == 0) a[p[i].sta].sta = i;
    a[p[i].sta].n++;
  }
  int bj = 1;
  for (int i = 0; i <= ma; i++) {
    if (i == 0) {
      if (a[0].n != 1) {
        bj = 0;
        break;
      }
    } else {
      if (i == 1) {
        if (a[i].n > a[i - 1].n * (long long)k) {
          bj = 0;
          break;
        }
      } else {
        if (a[i].n > a[i - 1].n * (long long)(k - 1)) {
          bj = 0;
          break;
        }
      }
    }
  }
  if (bj == 0)
    printf("-1\n");
  else {
    for (int i = 1; i <= n; i++) {
      if (p[i].sta == 0)
        continue;
      else {
        int x = i - a[p[i].sta].sta + 1;
        int y = a[p[i].sta - 1].n;
        int tmp = x % y;
        if (tmp == 0) tmp = a[p[i].sta - 1].n;
        x = a[p[i].sta - 1].sta + tmp - 1;
        y = i;
        data2 temp;
        temp.p = p[x].n;
        temp.q = p[y].n;
        que.push(temp);
      }
    }
    printf("%d\n", (int)que.size());
    while (!que.empty()) {
      data2 temp = que.front();
      que.pop();
      printf("%d %d\n", temp.p, temp.q);
    }
  }
  return 0;
}
