#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int nxt[maxn], beg[maxn], num[maxn];
int n, k, x;
int st;
int fa[maxn];
int main() {
  cin >> n >> k;
  st = -1;
  memset(beg, -1, sizeof(beg));
  memset(num, 0, sizeof(num));
  for (int i = 1; i <= n; i++) {
    cin >> x;
    nxt[i] = beg[x];
    beg[x] = i;
    num[x]++;
  }
  if (num[0] != 1) {
    cout << -1;
    return 0;
  }
  if (num[1] > k) {
    cout << -1;
    return 0;
  }
  for (int i = 2; i < n; i++)
    if (num[i - 1] * (k - 1LL) < num[i]) {
      cout << -1;
      return 0;
    }
  st = beg[0];
  int u, v;
  for (int i = 1; i < n; i++) {
    v = beg[i];
    for (u = beg[i - 1]; u != -1; u = nxt[u])
      for (int j = (i == 1) ? 0 : 1; j < k && v != -1; j++, v = nxt[v])
        fa[v] = u;
  }
  fa[st] = -1;
  cout << n - 1 << endl;
  for (int i = 1; i <= n; i++)
    if (i != st) cout << fa[i] << " " << i << endl;
  return 0;
}
