#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  pair<long long, long long> p[n];
  long long ct = 0;
  for (long long i = 0; i < n; i++) {
    cin >> p[i].first;
    if (p[i].first == 0) ct++;
    p[i].second = i + 1;
  }
  if (ct != 1) {
    cout << -1;
    return 0;
  }
  vector<pair<long long, long long> > ans;
  sort(p, p + n);
  vector<pair<long long, long long> > pr[p[n - 1].first + 1];
  for (long long i = 0; i < n; i++) {
    pr[p[i].first].push_back(p[i]);
  }
  for (long long i = 1; i <= p[n - 1].first; i++) {
    if (i == 1) {
      if (pr[i].size() > k) {
        cout << -1;
        return 0;
      }
      for (auto it : pr[i]) {
        ans.push_back(make_pair(pr[0][0].second, it.second));
      }
      continue;
    }
    if (pr[i].empty() || pr[i].size() > pr[i - 1].size() * (k - 1)) {
      cout << -1;
      return 0;
    }
    long long m = 0;
    long long n = 0;
    long long cnt = 0;
    while (n < pr[i].size() && m < pr[i - 1].size()) {
      while (cnt < k - 1 && n < pr[i].size()) {
        ans.push_back(make_pair(pr[i - 1][m].second, pr[i][n].second));
        cnt++;
        n++;
      }
      m++;
      cnt = 0;
    }
  }
  cout << ans.size() << endl;
  for (auto it : ans) {
    cout << it.first << " " << it.second << endl;
  }
  return 0;
}
