#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
struct cpp {
  int x, p;
};
cpp a[N];
int d[N], q[N];
vector<vector<int> > G(N);
bool cmp(cpp a, cpp b) { return a.x < b.x; }
int main() {
  int n, k;
  cin >> n >> k;
  int one = 0, zer = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i].x);
    if (a[i].x == 1) one++;
    if (a[i].x == 0) zer++;
    a[i].p = i;
  }
  if (one > k || zer != 1) return cout << "-1", 0;
  sort(a, a + n, cmp);
  for (int i = 0; i < n; i++) d[i] = -1;
  d[0] = 0;
  for (int i = 1; i < n; i++) {
    if (a[i].x != a[i - 1].x)
      d[a[i].x] = i, q[a[i - 1].x] = i - 1;
    else
      d[a[i].x] = d[a[i - 1].x];
  }
  q[a[n - 1].x] = n - 1;
  for (int i = n - 2; i > 0; i--)
    if (q[a[i].x] == 0) q[a[i].x] = q[a[i + 1].x];
  for (int i = 0; i < n; i++) {
    if (d[a[i].x] == -1 || (i > 1 && (q[a[i].x] - d[a[i].x] +
                                      1) / (q[a[i - 1].x] - d[a[i - 1].x] + 1) >
                                         k - 1))
      return cout << "-1", 0;
  }
  int ans = 0;
  for (int i = d[a[1].x]; i <= q[a[1].x]; i++) {
    G[a[0].p].push_back(a[i].p);
    ans++;
  }
  int l = d[a[1].x];
  for (int i = q[a[1].x] + 1; i < n;) {
    int t;
    if (a[i].x - a[i - 1].x != 1) return cout << "-1", 0;
    for (t = i; t <= q[a[i].x]; t++) {
      int w = (t - i) / (k - 1);
      G[a[l + w].p].push_back(a[t].p);
      ans++;
    }
    l = d[a[i].x];
    i = t;
  }
  printf("%d\n", ans);
  for (int i = 0; i < n; i++) {
    int v = a[i].p;
    size_t e = G[v].size();
    for (size_t j = 0; j < e; j++) printf("%d %d\n", v + 1, G[v][j] + 1);
  }
  return 0;
}
