#include <bits/stdc++.h>
using namespace std;
const int MAX = 100100;
int n, k, dep = 0;
vector<pair<int, int> > e;
vector<int> lev[MAX];
int deg[MAX];
void solve() {
  bool ok = 1;
  for (int i = 0; i < (dep); i++) {
    int cnt = 0, tot = lev[i].size();
    for (int j = 0; j < (lev[i + 1].size()); j++) {
      if (cnt < tot) {
        e.push_back(make_pair(lev[i][cnt], lev[i + 1][j]));
      } else {
        ok = 0;
        break;
      }
      deg[lev[i][cnt]]++;
      deg[lev[i + 1][j]]++;
      if (deg[lev[i][cnt]] == k) cnt++;
    }
    if (!ok) break;
  }
  for (int i = (1); i <= (n); i++) {
    if (deg[i] > k || !deg[i]) {
      ok = 0;
      break;
    }
  }
  if (ok) {
    printf("%d\n", e.size());
    for (int i = 0; i < (e.size()); i++) {
      printf("%d %d\n", e[i].first, e[i].second);
    }
  } else {
    printf("-1\n");
  }
  return;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < (n); i++) {
    int dist;
    scanf("%d", &dist);
    lev[dist].push_back(i + 1);
    dep = max(dep, dist);
  }
  solve();
  return 0;
}
