#include <bits/stdc++.h>
using namespace std;
struct FATE {
  int d, v;
};
struct UBW {
  int x, y;
};
bool cmp(FATE a, FATE b) { return a.d < b.d; }
FATE a[1000000];
UBW ans[1000000];
int e[1000000];
int n, kk;
int r;
int main() {
  memset(e, 0, sizeof e);
  memset(a, 0, sizeof a);
  scanf("%d%d", &n, &kk);
  int f = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i].d);
    a[i].v = i;
    f += (a[i].d == 0);
  }
  if (f != 1) {
    cout << -1 << endl;
    return 0;
  }
  sort(a + 1, a + n + 1, cmp);
  int k = 1, k1 = 0;
  int tot = 0;
  for (int i = 2; i <= n; i++) {
    if (a[i].d > a[i - 1].d + 1) {
      cout << -1 << endl;
      return 0;
    }
    if (a[i].d > a[i - 1].d) {
      r = k;
      k1 = k;
      k = i;
    }
    ++e[r];
    if (e[r] > kk) {
      cout << -1 << endl;
      return 0;
    }
    ans[++tot].x = a[r].v;
    ans[tot].y = a[i].v;
    ++e[i];
    if (e[i] > kk) {
      cout << -1 << endl;
      return 0;
    }
    r++;
    if (r == k) r = k1;
  }
  cout << tot << endl;
  for (int i = 1; i <= tot; i++) printf("%d %d\n", ans[i].x, ans[i].y);
  return 0;
}
