#include <bits/stdc++.h>
using namespace std;
vector<int> dis[111111];
int du[111111];
vector<pair<int, int> > ans;
int maxlen;
int n, k;
bool solve() {
  if (dis[0].size() != 1) return false;
  for (int i = 1; i <= maxlen; i++) {
    if (dis[i].size() == 0) return false;
    int before = 0;
    for (int j = 0; j < dis[i].size(); j++) {
      int be = dis[i - 1][before];
      int cur = dis[i][j];
      if (du[be] >= k) {
        before++;
        if (before >= dis[i - 1].size()) return false;
        be = dis[i - 1][before];
      }
      du[be]++;
      du[cur]++;
      ans.push_back(pair<int, int>(be, cur));
    }
  }
  return true;
}
int main() {
  cin >> n >> k;
  maxlen = -1;
  for (int i = 1; i <= n; i++) {
    int t;
    scanf("%d", &t);
    maxlen = max(maxlen, t);
    dis[t].push_back(i);
  }
  if (solve()) {
    printf("%d\n", ans.size());
    for (int i = 0; i < ans.size(); i++)
      printf("%d %d\n", ans[i].first, ans[i].second);
  } else
    cout << -1 << endl;
  return 0;
}
