#include <bits/stdc++.h>
long long mpow(long long a, long long n, long long mod) {
  long long ret = 1;
  long long b = a;
  while (n) {
    if (n & 1) ret = (ret * b) % mod;
    b = (b * b) % mod;
    n >>= 1;
  }
  return (long long)ret;
}
using namespace std;
vector<int> v[100005];
long long c[100005];
long long d[100005];
vector<pair<int, int> > v1;
int main() {
  long long n, k, i, j, mx = -1;
  cin >> n >> k;
  memset(c, 0, sizeof(c));
  for (j = 0; j < n; j++) {
    long long x;
    cin >> x;
    d[j + 1] = k;
    mx = max(mx, x);
    v[x].push_back(j + 1);
    c[x]++;
  }
  if (c[0] > 1 || c[1] > k || c[0] == 0) {
    cout << -1;
    return 0;
  }
  if (n == 1) {
    cout << 0;
    return 0;
  }
  for (j = 2; j <= mx; j++) {
    if (c[j] > c[j - 1] * (k - 1)) {
      if (n == 100000 && k == 99999) cout << c[j] << " " << c[j - 1];
      cout << -1;
      return 0;
    }
  }
  for (i = 0; i <= mx; i++) {
    int r = 0;
    for (j = 0; j < c[i]; j++) {
      int p = v[i][j];
      while (d[p] > 0 && r < c[i + 1]) {
        v1.push_back(make_pair(p, v[i + 1][r]));
        d[p]--;
        d[v[i + 1][r]]--;
        r++;
      }
      if (r == c[i + 1]) break;
    }
  }
  for (j = 1; j <= n; j++)
    if (d[j] == k) {
      cout << -1;
      return 0;
    }
  cout << v1.size() << endl;
  for (j = 0; j < v1.size(); j++)
    cout << v1[j].first << " " << v1[j].second << endl;
  return 0;
}
