#include <bits/stdc++.h>
using namespace std;
int cmp(pair<int, int> a, pair<int, int> b) { return a.second < b.second; }
struct type {
  int v, num, level;
  type(int a, int b, int c) {
    v = a;
    num = b;
    level = c;
  }
};
int main() {
  int n, k;
  cin >> n >> k;
  pair<int, int> *dist = new pair<int, int>[n];
  for (int i = 0; i < n; i++) {
    cin >> dist[i].second;
    dist[i].first = i;
  }
  sort(dist, dist + n, cmp);
  vector<type> q;
  vector<pair<int, int> > result;
  int cur_v = 0;
  if (dist[0].second != 0) {
    cout << -1 << endl;
    return 0;
  }
  type tmp(dist[0].first, 0, 0);
  q.push_back(tmp);
  int cur_d = 0, cur_lev = 0;
  for (int i = 1; i < n; i++) {
    if (dist[i].second != cur_lev) {
      if (dist[i].second != cur_lev + 1) {
        cout << -1 << endl;
        return 0;
      }
      cur_lev++;
      while (cur_v < q.size() && cur_lev - 2 == q[cur_v].level) cur_v++;
      if (cur_v == q.size()) {
        cout << -1 << endl;
        return 0;
      }
    }
    while (q[cur_v].num == k) {
      cur_v++;
      if (cur_v == q.size()) {
        cout << -1 << endl;
        return 0;
      }
    }
    if (q[cur_v].level != cur_lev - 1) {
      cout << -1 << endl;
      return 0;
    }
    q[cur_v].num++;
    pair<int, int> edge(q[cur_v].v + 1, dist[i].first + 1);
    result.push_back(edge);
    type tmp(dist[i].first, 1, cur_lev);
    q.push_back(tmp);
  }
  cout << result.size() << endl;
  for (int i = 0; i < result.size(); i++) {
    cout << result[i].first << " " << result[i].second << endl;
  }
  cout << endl;
  return 0;
}
