#include <bits/stdc++.h>
using namespace std;
long long n, k;
pair<long long, long long> d[100100];
long long cnt[100100];
vector<long long> G[100100];
long long deg[100100];
void dfs(long long root = d[1].second) {
  for (auto& ch : G[root]) {
    cout << root << ' ' << ch << '\n';
    dfs(ch);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  cin >> n >> k;
  for (long long i = 1; i <= n; i++) cin >> d[i].first, d[i].second = i;
  sort(d + 1, d + 1 + n);
  if (d[1].first != 0 or d[2].first == 0) {
    cout << -1 << '\n';
    return 0;
  }
  for (long long i = 1; i <= n; i++) cnt[d[i].first]++;
  if (cnt[1] > k) {
    cout << -1 << '\n';
    return 0;
  }
  for (long long dp = 2; dp <= d[n].first; dp++)
    if (cnt[dp] > (k - 1) * cnt[dp - 1]) {
      cout << -1 << '\n';
      return 0;
    }
  memset(deg, 0, sizeof deg);
  for (long long j = 1, i = 2; i <= n; i++) {
    while (d[j].first < d[i].first - 1 or deg[d[j].second] == k) j++;
    deg[d[j].second]++, deg[d[i].second]++;
    G[d[j].second].push_back(d[i].second);
  }
  cout << n - 1 << '\n';
  dfs();
  return 0;
};
