#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  int distance;
  vector<int> dist[100000];
  for (int i = 0; i < n; i++) {
    cin >> distance;
    dist[distance].push_back(i);
  }
  if (dist[0].size() != 1) {
    cout << -1;
    return 0;
  }
  if (dist[1].size() > k) {
    cout << -1;
    return 0;
  }
  for (int i = 2; i < n; i++) {
    if ((long long)dist[i].size() > (long long)(k - 1) * dist[i - 1].size()) {
      cout << -1;
      return 0;
    }
  }
  cout << n - 1 << endl;
  for (int j = 0; j < dist[1].size(); j++) {
    cout << dist[0][0] + 1 << " " << dist[1][j] + 1 << endl;
  }
  for (int i = 2; i < n; i++) {
    for (int j = 0; j < dist[i].size(); j++) {
      cout << dist[i - 1][j / (k - 1)] + 1 << " " << dist[i][j] + 1 << endl;
    }
  }
  return 0;
}
