#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
vector<int> d[N];
int degree[N];
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    int x;
    scanf("%d", &x);
    d[x].emplace_back(i);
  }
  if (d[0].size() != 1) return !printf("-1\n");
  for (int i = 1; i < n; ++i)
    if (!d[i].empty() && d[i - 1].empty()) return !printf("-1\n");
  vector<pair<int, int> > Vp;
  for (int i = 1;; i++) {
    if (d[i].empty()) break;
    for (int j = 0, x = 0; j < (int)d[i].size(); j++) {
      if (degree[d[i - 1][x]] == k) x++;
      if (x >= d[i - 1].size()) return !printf("-1\n");
      Vp.emplace_back(d[i - 1][x], d[i][j]);
      degree[d[i - 1][x]]++;
      degree[d[i][j]]++;
    }
  }
  cout << Vp.size() << endl;
  for (auto i : Vp) printf("%d %d\n", i.first, i.second);
}
