#include <bits/stdc++.h>
using namespace std;
struct node {
  int id, w;
} dis[100005];
int c[100005];
bool cmp(node a, node b) { return a.w < b.w; }
int ans[1000005][2];
int cnt;
int main() {
  int n, k;
  while (~scanf("%d%d", &n, &k)) {
    cnt = 0;
    memset(c, 0, sizeof(c));
    for (int i = 1; i <= n; i++) {
      scanf("%d", &dis[i].w);
      dis[i].id = i;
    }
    sort(dis + 1, dis + n + 1, cmp);
    if (dis[1].w != 0 || dis[2].w == 0) {
      printf("-1\n");
      continue;
    }
    int pre = 1;
    int cur = 1;
    int pc = 1;
    int f = 1;
    for (int i = 2; i <= n; i++) {
      if (dis[i].w == dis[i - 1].w) {
        if (pc > n || dis[pc].w != dis[i].w - 1) {
          f = 0;
          break;
        }
        c[pc]++;
        c[i]++;
        ans[cnt][0] = dis[pc].id;
        ans[cnt][1] = dis[i].id;
        cnt++;
        while (pc <= n && c[pc] >= k) pc++;
      } else if (dis[i].w == dis[i - 1].w + 1) {
        pre = cur;
        cur = i;
        pc = pre;
        while (pc <= n && c[pc] >= k) pc++;
        if (pc > n || dis[pc].w != dis[i].w - 1) {
          f = 0;
          break;
        }
        c[pc]++;
        c[i]++;
        ans[cnt][0] = dis[pc].id;
        ans[cnt][1] = dis[i].id;
        cnt++;
        while (pc <= n && c[pc] >= k) pc++;
      } else {
        f = 0;
        break;
      }
    }
    if (f == 0) {
      printf("-1\n");
    } else {
      printf("%d\n", cnt);
      for (int i = 0; i < cnt; i++) {
        printf("%d %d\n", ans[i][0], ans[i][1]);
      }
    }
  }
}
