#include <bits/stdc++.h>
using namespace std;
vector<int> adj[(int)1e5 + 20];
vector<int> levels[(int)1e5 + 20];
int main() {
  long long n, k;
  int x;
  cin >> n >> k;
  int to = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    to = max(to, x);
    levels[x].push_back(i + 1);
  }
  bool ok = true;
  ok &= levels[0].size() == 1;
  if (ok) {
    int tot = 0;
    for (int i = 0; i + 1 <= to; i++) {
      if (levels[i + 1].size() > k * levels[i].size()) {
        ok = false;
        break;
      }
      if (i == 0) k--;
      int c = 0;
      for (int j = 0; j < levels[i + 1].size(); j++) {
        adj[levels[i + 1][j]].push_back(levels[i][c]);
        tot++;
        c++;
        if (c == levels[i].size()) c = 0;
      }
    }
    if (ok) {
      cout << tot << endl;
      for (int i = 1; i <= n; i++) {
        for (int j = 0; j < adj[i].size(); j++) {
          printf("%d %d\n", i, adj[i][j]);
        }
      }
    }
  }
  if (!ok) {
    cout << -1 << endl;
  }
  return 0;
}
