#include <bits/stdc++.h>
using namespace std;
const int N = 110000;
int d[N], id[N], deg[N], st[N];
vector<pair<int, int>> ans;
int main() {
  ios_base::sync_with_stdio(0);
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> d[i];
  int cnt = 0;
  for (int i = 1; i <= n; i++) cnt += !d[i];
  if (cnt != 1) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 1; i <= n; i++) id[i] = i;
  sort(id + 1, id + n + 1, [&](int u, int v) { return d[u] < d[v]; });
  for (int i = n; i >= 1; i--) st[d[id[i]]] = i;
  for (int i = 2; i <= n; i++) {
    int u = id[i];
    int rt = st[d[u] - 1];
    while (deg[id[rt]] == k) st[d[u] - 1]++, rt++;
    if (d[id[rt]] != d[u] - 1) {
      cout << -1 << endl;
      return 0;
    }
    deg[id[rt]]++, deg[u]++;
    ans.emplace_back(id[rt], u);
  }
  cout << ans.size() << endl;
  for (auto it : ans) cout << it.first << " " << it.second << endl;
  return 0;
}
