#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  vector<pair<int, int> > d;
  d.resize(N);
  for (int i = 0; i < N; ++i) {
    cin >> d[i].first;
    d[i].second = i;
  }
  sort(d.begin(), d.end());
  if (d[0].first != 0) {
    cout << -1 << endl;
    return 0;
  }
  if (d[1].first == 0) {
    cout << -1 << endl;
    return 0;
  }
  vector<int> count;
  vector<pair<int, int> > ans;
  count.resize(N, 0);
  int prev_begin = 0;
  int prev_end = 1;
  int prev_curr = 0;
  int curr_begin = 0;
  for (int i = 1; i < N; ++i) {
    if (d[i].first != d[i - 1].first) {
      if (d[i].first != d[i - 1].first + 1) {
        cout << -1 << endl;
        return 0;
      }
      prev_begin = curr_begin;
      prev_end = i - 1;
      prev_curr = prev_begin;
      curr_begin = i;
    }
    ans.push_back(make_pair(d[i].second, d[prev_curr].second));
    count[d[i].second]++;
    if (count[d[i].second] > K) {
      cout << -1 << endl;
      return 0;
    }
    count[d[prev_curr].second]++;
    if (count[d[prev_curr].second] > K) {
      cout << -1 << endl;
      return 0;
    }
    prev_curr++;
    if (prev_curr > prev_end) prev_curr = prev_begin;
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); ++i) {
    cout << ans[i].first + 1 << " " << ans[i].second + 1 << endl;
  }
  return 0;
}
