#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void umax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
inline void umin(T &a, T b) {
  if (a > b) a = b;
}
template <class T>
inline T abs(T a) {
  return a > 0 ? a : -a;
}
template <class T>
inline T gcd(T a, T b) {
  return __gcd(a, b);
}
template <class T>
inline T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
long long modpow(long long a, long long n, long long temp) {
  long long res = 1, y = a;
  while (n > 0) {
    if (n & 1) res = (res * y) % temp;
    y = (y * y) % temp;
    n /= 2;
  }
  return res % temp;
}
long long ison(long long mask, long long pos) { return (mask & (1 << pos)); }
long long cbit(long long n) {
  long long k = 0;
  while (n) n &= (n - 1), k++;
  return k;
}
long long nbit(long long n) {
  long long k = 0;
  while (n) n /= 2, k++;
  return k;
}
long long mod = 1e9 + 7;
int sgn(long long x) { return x < 0 ? -1 : !!x; }
long long xo(long long i) {
  if ((i & 3) == 0) return i;
  if ((i & 3) == 1) return 1;
  if ((i & 3) == 2) return i + 1;
  return 0;
}
vector<long long> adj[100005];
vector<long long> ans[100005];
int main() {
  long long i, j, k, l, m, n;
  ios_base::sync_with_stdio(0);
  cin >> n >> k;
  long long ma = 0;
  for (i = 1; i <= n; i++) {
    cin >> j;
    ma = max(ma, j);
    adj[j].push_back(i);
  }
  if (adj[0].size() != 1) {
    cout << -1;
    return 0;
  }
  priority_queue<pair<long long, long long> > q;
  q.push(make_pair(k, adj[0][0]));
  for (i = 1; i <= ma; i++) {
    for (j = 0; j < adj[i].size(); j++) {
      if (q.empty()) {
        cout << -1;
        return 0;
      }
      long long v = q.top().second;
      long long p = q.top().first;
      q.pop();
      ans[v].push_back(adj[i][j]);
      ans[adj[i][j]].push_back(v);
      p--;
      if (p > 0) q.push(make_pair(p, v));
    }
    while (!q.empty()) q.pop();
    for (j = 0; j < adj[i].size(); j++) {
      long long v = adj[i][j];
      if (k - 1 > 0) q.push(make_pair(k - 1, v));
    }
  }
  set<pair<long long, long long> > chk;
  for (i = 1; i <= n; i++) {
    for (j = 0; j < ans[i].size(); j++) {
      long long x = i;
      long long y = ans[i][j];
      chk.insert(make_pair(min(x, y), max(x, y)));
    }
  }
  cout << chk.size() << endl;
  set<pair<long long, long long> >::iterator it;
  for (it = chk.begin(); it != chk.end(); it++)
    cout << (*it).first << " " << (*it).second << endl;
}
