#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio();
  cin.tie(0);
  cout.tie(0);
  int64_t n, k;
  cin >> n >> k;
  vector<int64_t> mass[n];
  for (int64_t i = 0; i < n; ++i) {
    int64_t cur;
    cin >> cur;
    mass[cur].push_back(i);
  }
  if (((int64_t)mass[0].size()) != 1 || ((int64_t)mass[1].size()) > k) {
    cout << -1;
    return 0;
  }
  for (int64_t i = 2; i < n; ++i) {
    int64_t val = ((int64_t)mass[i - 1].size()) * (k - 1);
    if (val < ((int64_t)mass[i].size())) {
      cout << -1 << '\n';
      return 0;
    }
  }
  cout << n - 1 << '\n';
  for (int64_t v : mass[1]) cout << mass[0][0] + 1 << " " << v + 1 << '\n';
  for (int64_t i = 2; i < n; ++i)
    for (int64_t j = 0; j < ((int64_t)mass[i].size()); ++j)
      cout << mass[i][j] + 1 << " " << mass[i - 1][j / (k - 1)] + 1 << '\n';
  return 0;
}
