#include <bits/stdc++.h>
using namespace std;
int c[100009];
int main() {
  memset(c, 0, sizeof(c));
  int n, k;
  scanf("%d %d", &n, &k);
  vector<vector<int> > v(n + 1);
  vector<pair<int, int> > z;
  for (int i = 0; i < n; i++) {
    int tmp;
    scanf("%d", &tmp);
    v[tmp].push_back(i + 1);
  }
  if (v[0].size() != 1) {
    cout << "-1\n";
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    if (v[i].size() > 0 && v[i - 1].size() == 0) {
      cout << "-1\n";
      return 0;
    }
    int ind = 0;
    for (int j = 0; j < v[i].size(); j++) {
      if (c[v[i - 1][ind]] == k) ind++;
      if (ind == v[i - 1].size()) {
        cout << "-1\n";
        return 0;
      }
      z.push_back(make_pair(v[i - 1][ind], v[i][j]));
      c[v[i - 1][ind]]++;
      c[v[i][j]]++;
    }
  }
  printf("%d\n", (int)z.size());
  for (auto &x : z) printf("%d %d\n", x.first, x.second);
  return 0;
}
