#include <bits/stdc++.h>
using namespace std;
long long power(long long b, long long e, long long m) {
  if (e == 0) return 1;
  if (e & 1) return b * power(b * b % m, e / 2, m) % m;
  return power(b * b % m, e / 2, m);
}
long long power(long long b, long long e) {
  if (e == 0) return 1;
  if (e & 1) return b * power(b * b, e / 2);
  return power(b * b, e / 2);
}
vector<vector<long long>> v;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  long long d[n];
  v.resize(n + 1);
  for (long long i = 0; i < n; i++) {
    cin >> d[i];
    v[d[i]].push_back(i + 1);
  }
  long long f = 1;
  if (v[0].size() != 1) f = 0;
  if (v[1].size() > k) f = 0;
  if (f) {
    long long m = v[1].size();
    for (long long i = 2; i <= n; i++) {
      if (((long long)v[i].size()) > ((long long)((k - 1) * m))) {
        f = 0;
        break;
      } else
        m = (v[i].size());
    }
  }
  if (f) {
    cout << n - 1 << "\n";
    for (auto i : v[1]) cout << v[0][0] << " " << i << "\n";
    for (long long i = 2; i <= n; i++) {
      long long cur = 0, y = 0;
      for (auto j : v[i]) {
        cout << v[i - 1][cur] << " " << j << "\n";
        y++;
        if (y == (k - 1)) {
          y = 0;
          cur++;
        }
      }
    }
  } else
    cout << "-1";
  return 0;
}
