#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const double pi = acos(-1.0);
int n, k, deg[111111];
vector<pair<int, int> > ans;
pair<int, int> d[111111];
int main() {
  scanf("%d%d", &n, &k);
  int zero = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &d[i].first);
    d[i].second = i;
    if (d[i].first == 0) zero++;
  }
  if (zero != 1) {
    puts("-1");
    return 0;
  }
  sort(d, d + n);
  int p = 0;
  for (int i = 1; i < n; ++i) {
    if (d[i].first != d[i - 1].first) {
      if (d[i].first != d[i - 1].first + 1) {
        puts("-1");
        return 0;
      }
      while (p < i && d[p].first != d[i].first - 1) p++;
    }
    if (deg[p] < k) {
      ans.push_back(make_pair(d[p].second + 1, d[i].second + 1));
      deg[p]++;
      deg[i]++;
    } else {
      p++;
      if (d[p].first != d[i].first - 1) {
        puts("-1");
        return 0;
      }
      ans.push_back(make_pair(d[p].second + 1, d[i].second + 1));
      deg[p]++;
      deg[i]++;
    }
  }
  printf("%d\n", int((ans).size()));
  for (int i = 0; i < int((ans).size()); ++i)
    printf("%d %d\n", ans[i].first, ans[i].second);
  return 0;
}
