#include <bits/stdc++.h>
using namespace std;
const long double pi = acos(-1.0);
const double EPS = 1E-5;
const int INF = 2 * (1e+9) + 1;
const int NMAX = 32000;
const int MOD = 1e+25;
long long n, k, st, en;
vector<vector<int> > d, g;
int main() {
  cin >> n >> k;
  g.resize(n + 1);
  d.resize(n + 1);
  for (int i = 0; i < (n); ++i) {
    long long t;
    cin >> t;
    d[t].push_back(i);
    en = max(t, en);
    if (t == 0) st = i;
  }
  if ((long long)(d[0]).size() != 1) {
    cout << -1;
    return 0;
  }
  for (int cur = (1); cur <= (en); ++cur) {
    int prev = 0;
    if ((long long)(d[cur]).size() == 0 ||
        (long long)(d[cur]).size() > k * (long long)(d[cur - 1]).size()) {
      cout << -1;
      return 0;
    }
    for (int i = 0; i < ((long long)(d[cur]).size()); ++i) {
      int from = d[cur - 1][prev];
      if ((long long)(g[from]).size() >= k) prev++;
      if (prev >= (long long)(d[cur - 1]).size()) {
        cout << -1;
        return 0;
      }
      from = d[cur - 1][prev];
      int to = d[cur][i];
      if ((long long)(g[from]).size() < k) {
        g[from].push_back(to);
        g[to].push_back(from);
      }
    }
  }
  set<pair<int, int> > s;
  for (int i = 0; i < ((long long)(g).size()); ++i) {
    for (int j = 0; j < ((long long)(g[i]).size()); ++j) {
      int t1 = i + 1, t2 = g[i][j] + 1;
      if (t1 > t2) swap(t1, t2);
      s.insert(make_pair(t1, t2));
    }
  }
  cout << (long long)(s).size() << endl;
  for (auto it = s.begin(); it != s.end(); it++) {
    cout << it->first << " " << it->second << endl;
  }
}
