#include <bits/stdc++.h>
using namespace std;
vector<vector<int64_t>> p;
int64_t k;
vector<pair<int64_t, int64_t>> ans;
int64_t c = 0;
vector<int64_t> colv;
void f(int64_t i) {
  int64_t n = 0;
  int64_t v = 0;
  for (int64_t j = 0; j < p[i].size(); j++) {
    if (n >= k - 1 && i != 1) {
      v++;
      n = 1;
    } else
      n++;
    ans.push_back({p[i - 1][v] + 1, p[i][j] + 1});
    c++;
  }
}
int32_t main() {
  int64_t n;
  int64_t m = 0;
  cin >> n >> k;
  p.resize(n);
  colv.resize(n);
  for (int64_t i = 0; i < n; i++) {
    int64_t t;
    cin >> t;
    m = max(m, t);
    p[t].push_back(i);
  }
  if (p[0].size() != 1) {
    cout << "-1";
    return 0;
  }
  if (m > 0) {
    if (p[0].size() * k < p[1].size() || p[1].size() == 0) {
      cout << "-1";
      return 0;
    }
  }
  for (int64_t i = 2; i <= m; i++) {
    if (p[i - 1].size() * (k - 1) < p[i].size() || p[i].size() == 0) {
      cout << "-1";
      return 0;
    }
  }
  for (int64_t i = 1; i <= m; i++) {
    f(i);
  }
  cout << c << endl;
  for (auto to : ans) {
    cout << to.first << " " << to.second << endl;
  }
  return 0;
}
