#include <bits/stdc++.h>
using namespace std;
vector<int> g[100100];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  pair<int, int> d[n];
  bool zero = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &d[i].first);
    if (d[i].first == 0) zero = 1;
    d[i].second = i;
  }
  if (zero == 0) {
    puts("-1");
    return 0;
  }
  sort(d, d + n);
  int cnt = 0;
  int cntv[n];
  memset(cntv, 0, sizeof cntv);
  queue<int> have[n + 1];
  have[1].push(d[0].second);
  for (int i = 1; i < n; i++) {
    if (have[d[i].first].size() == 0) {
      puts("-1");
      return 0;
    }
    int u = have[d[i].first].front();
    if (u < d[i].second)
      g[u].push_back(d[i].second);
    else
      g[d[i].second].push_back(u);
    cnt++;
    if (++cntv[u] == k) have[d[i].first].pop();
    cntv[d[i].second]++;
    if (cntv[d[i].second] < k) have[d[i].first + 1].push(d[i].second);
  }
  printf("%d\n", cnt);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < (int)g[i].size(); j++)
      printf("%d %d\n", i + 1, g[i][j] + 1);
  }
}
