#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100001;
int n, k, ma, st;
int d[MAX_N], deg[MAX_N];
vector<int> dd[MAX_N];
vector<pair<int, int> > ans;
void solve() {
  int fa = st;
  for (int i = 1; i <= ma; ++i) {
    int l = (int)dd[i].size();
    if (l == 0) {
      puts("-1");
      return;
    }
    int j = 0;
    while (j < l) {
      if (deg[fa] < k && j < l) {
        ++deg[fa], ++deg[dd[i][j]];
        ans.push_back(make_pair(fa, dd[i][j]));
        ++j;
      } else {
        int h;
        for (h = 0; h < (int)dd[i - 1].size(); ++h) {
          if (deg[dd[i - 1][h]] < k) {
            fa = dd[i - 1][h];
            break;
          }
        }
        if (h == (int)dd[i - 1].size()) {
          puts("-1");
          return;
        }
      }
    }
    if (j == l) fa = dd[i][l - 1];
  }
  int t = (int)ans.size();
  printf("%d\n", t);
  for (int i = 0; i < t; ++i) {
    printf("%d %d\n", ans[i].first, ans[i].second);
  }
}
int main() {
  scanf("%d%d", &n, &k);
  int z = 0;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &d[i]);
    if (d[i] == 0) ++z, st = i;
    if (d[i] != 0) dd[d[i]].push_back(i), ma = max(ma, d[i]);
  }
  if (z > 1 || z == 0)
    puts("-1");
  else
    solve();
  return 0;
}
