#include <bits/stdc++.h>
using namespace std;
int c[100005];
struct node {
  int f;
  int t;
};
int main() {
  vector<int> v[100005];
  vector<node> v2;
  int n, k, cnt = 0, d;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    int d;
    cin >> d;
    if (d == 0) {
      cnt++;
    }
    v[d].push_back(i);
  }
  if (cnt != 1) {
    cout << "-1" << '\n';
    return 0;
  }
  for (int i = 1; i < 100005; i++) {
    int cx = 0, in = 0;
    for (int j = 0; j < v[i].size(); j++) {
      while (in < v[i - 1].size() && c[v[i - 1][in]] >= k) {
        in++;
      }
      if (in == v[i - 1].size()) {
        cout << "-1" << '\n';
        return 0;
      }
      node x;
      x.f = v[i - 1][in];
      x.t = v[i][j];
      c[v[i - 1][in]]++;
      c[v[i][j]]++;
      v2.push_back(x);
    }
  }
  cout << v2.size() << "\n";
  for (int i = 0; i < v2.size(); i++) {
    cout << v2[i].f << " " << v2[i].t << "\n";
  }
  return 0;
}
