#include <bits/stdc++.h>
using namespace std;
int dis[100005];
int ord[100005];
int num[100005];
int V[100005], U[100005];
int cnt, n, k;
bool cmp(int a, int b) { return dis[a] < dis[b]; }
int main() {
  while (~scanf("%d%d", &n, &k)) {
    int i, j;
    memset(num, 0, sizeof(num));
    cnt = 0;
    for (i = 0; i < n; i++) {
      scanf("%d", &dis[i]);
      ord[i] = i;
      num[dis[i]]++;
    }
    sort(ord, ord + n, cmp);
    bool ok = true;
    int v, u = 1, deg = 0;
    if (num[0] != 1 || num[1] > k) {
      ok = false;
    } else {
      for (i = 1; num[i]; i++) {
        v = u - 1;
        if (i != 1 && num[i] > (long long)num[i - 1] * (k - 1)) {
          ok = false;
          break;
        }
        for (j = 1; j <= num[i]; j++) {
          if (deg == k) {
            v--;
            deg = 1;
          }
          V[cnt] = v;
          U[cnt] = u++;
          cnt++;
          deg++;
        }
        deg = 1;
      }
      if (i != dis[ord[n - 1]] + 1) ok = false;
    }
    if (!ok)
      printf("-1\n");
    else {
      printf("%d\n", cnt);
      for (i = 0; i < cnt; i++) {
        printf("%d %d\n", ord[V[i]] + 1, ord[U[i]] + 1);
      }
    }
  }
}
