#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
const long long INFL = LLONG_MAX;
int N, K, deg[100100], D[100100];
stack<int> depth[100100];
void dfs(int n, int d) {
  while (deg[n] < K && depth[d + 1].size()) {
    cout << n << ' ' << depth[d + 1].top() << '\n';
    deg[n]++;
    deg[depth[d + 1].top()]++;
    dfs(depth[d + 1].top(), d + 1);
    depth[d + 1].pop();
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cout.precision(15);
  cin >> N >> K;
  for (int(i) = 1; (i) <= (N); (i)++) cin >> D[i], depth[D[i]].push(i);
  bool possible = depth[0].size() == 1;
  possible &= depth[1].size() <= K;
  for (int(i) = 1; (i) <= (N); (i)++)
    possible &= depth[i].size() * 1LL * (K - 1) >= depth[i + 1].size();
  if (possible) {
    cout << N - 1 << '\n';
    dfs(depth[0].top(), 0);
  } else {
    cout << -1 << '\n';
    return 0;
  }
}
