#include <bits/stdc++.h>
using namespace std;
const int Max = (int)1e5 + 5;
pair<int, int> d[Max];
vector<int> ady[Max];
bool visited[Max];
int degree[Max];
void out() {
  cout << -1 << endl;
  exit(0);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  bool found = false;
  for (int i = 1; i <= n; i++) {
    cin >> d[i].first;
    d[i].second = i;
    if (d[i].first >= n) out();
    if (d[i].first == 0) {
      if (!found)
        found = true;
      else
        out();
    }
  }
  if (!found) out();
  sort(d + 1, d + n + 1);
  int curr_dist = 1;
  bool chg;
  int m = 0;
  int st1 = 1, st2 = 2;
  for (int i = 1, v = 2; i <= n; i++) {
    chg = true;
    if (d[v].first - d[i].first == 0)
      out();
    else if (d[v].first - d[i].first > 1)
      i = st1;
    if (d[v].first - d[i].first > 1) out();
    while (v <= n and d[v].first == curr_dist) {
      if (degree[d[i].second] >= k or degree[d[v].second] >= k) {
        curr_dist--;
        chg = false;
        break;
      }
      degree[d[i].second]++;
      degree[d[v].second]++;
      ady[d[i].second].push_back(d[v].second);
      ady[d[v].second].push_back(d[i].second);
      m++;
      v++;
    }
    curr_dist++;
    if (chg) {
      st1 = st2;
      st2 = v;
    }
    if (v > n) break;
  }
  cout << m << endl;
  for (int v = 1; v <= n; v++) {
    if (visited[v]) continue;
    visited[v] = true;
    for (auto n : ady[v]) {
      if (visited[n]) continue;
      cout << v << " " << n << endl;
    }
  }
  return 0;
}
