#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int n, k;
int a[1111111], cnt[1111111];
vector<int> p[1111111];
int main() {
  int t, x, y, z, ca = 1, mm = 0, st;
  scanf("%d%d", &(n), &(k));
  for (int i = (int)(1); i <= (int)(n); ++i) {
    scanf("%d", &(a[i]));
    cnt[a[i]]++;
    p[a[i]].push_back(i);
    mm = max(mm, a[i]);
    if (a[i] == 0) st = i;
  }
  int bad = 0;
  for (int i = (int)(0); i <= (int)(mm); ++i) {
    if (cnt[i] == 0) bad = 1;
  }
  if (cnt[0] != 1) bad = 1;
  if (1ll * cnt[1] > 1ll * k * cnt[0]) bad = 1;
  for (int i = (int)(2); i <= (int)(mm); ++i) {
    if (1ll * cnt[i] > 1ll * (k - 1) * cnt[i - 1]) bad = 1;
  }
  if (k == 1 && mm > 1) bad = 1;
  if (bad)
    puts("-1");
  else {
    printf("%d\n", (n - 1));
    int pos = 0;
    for (int tt = 0; tt < (int)(p[1].size()); ++tt) {
      printf("%d %d\n", p[0][pos], p[1][tt]);
      if (tt % k == k - 1) pos++;
    }
    for (int i = (int)(1); i <= (int)(mm - 1); ++i) {
      int j = 0;
      for (int tt = 0; tt < (int)(p[i + 1].size()); ++tt) {
        printf("%d %d\n", p[i][j], p[i + 1][tt]);
        if (tt % (k - 1) == k - 2) j++;
      }
    }
  }
  return 0;
}
