#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> d(n);
  for (int i = 0; i < n; i++) cin >> d[i];
  int cnt_zero = 0, mx = 0;
  set<int> s;
  for (int i = 0; i < n; i++) {
    if (d[i] == 0) {
      if (cnt_zero > 0) {
        cout << "-1" << endl;
        return 0;
      }
      cnt_zero++;
    }
    mx = max(mx, d[i]);
    s.insert(d[i]);
  }
  for (int i = mx; i >= 0; i--) {
    if (s.find(i) == s.end()) {
      cout << "-1" << endl;
      return 0;
    }
  }
  vector<vector<int>> h(mx + 1);
  vector<vector<int>> qnt(mx + 1);
  for (int i = 0; i < n; i++) qnt[d[i]].push_back(i + 1);
  vector<pair<int, int>> ans;
  h[0].push_back(qnt[0][0]);
  for (int i = 1; i <= mx; i++) {
    int done = 0;
    int qi = qnt[i].size(), qant = qnt[i - 1].size();
    int teto = (qi + qant - 1) / qant;
    if ((i == 1 && teto > k) || (i > 1 && teto > k - 1)) {
      cout << "-1" << endl;
      return 0;
    }
    for (int j = 0; j < h[i - 1].size(); j++) {
      teto = ((qi - done) + (qant - j) - 1) / (qant - j);
      for (int l = done; l < done + teto; l++) {
        ans.push_back(make_pair(h[i - 1][j], qnt[i][l]));
        h[i].push_back(qnt[i][l]);
      }
      done += teto;
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
  return 0;
}
