#include <bits/stdc++.h>
using namespace std;
const int MAXINT = 0x6fffffff;
const long long MAXLONG = (long long)1 << 63 - 1;
const int MAXM = 1e5 + 5;
vector<int> dd[MAXM];
long long n, k;
int main() {
  while (cin >> n >> k) {
    for (long long i = (0); i < (n + 1); i += 1) {
      dd[i].clear();
    }
    for (long long i = (1); i < (n + 1); i += 1) {
      int d;
      scanf("%d", &d);
      dd[d].push_back(i);
    }
    bool ok = true;
    if (dd[0].size() != 1) {
      puts("-1");
      continue;
    }
    for (long long i = (1); i < (n + 1); i += 1) {
      long long can = dd[i - 1].size() * k;
      if (i > 1) {
        can -= dd[i - 1].size();
      }
      if (can < dd[i].size()) {
        ok = false;
        break;
      }
    }
    if (!ok) {
      puts("-1");
      continue;
    }
    printf("%d\n", n - 1);
    for (long long i = (1); i < (n + 1); i += 1) {
      int pre_sz = dd[i - 1].size();
      int idx = 0;
      for (long long j = (0); j < (pre_sz); j += 1) {
        int most = i == 1 ? k : k - 1;
        for (long long h = (0); h < (most); h += 1) {
          if (idx >= dd[i].size()) {
            break;
          }
          printf("%d %d\n", dd[i - 1][j], dd[i][idx]);
          idx++;
        }
      }
    }
  }
  return 0;
}
