#include <bits/stdc++.h>
using namespace std;
int n, k;
int d[100005], nr[100005];
vector<int> f[100005];
vector<pair<int, int> > sol;
int main() {
  scanf("%d %d", &n, &k);
  int i;
  for (i = 1; i <= n; i++) {
    scanf("%d", &d[i]);
    f[d[i]].push_back(i);
  }
  if (f[0].size() != 1 || f[1].size() > k) {
    printf("-1\n");
    return 0;
  }
  for (i = n; i >= 1; i--)
    if (f[i].size() && f[i - 1].empty()) {
      printf("-1\n");
      return 0;
    }
  for (i = 1; i <= n; i++) {
    if (f[i + 1].size()) {
      if (f[i + 1].size() > f[i].size() * ((long long)k - 1)) {
        printf("-1\n");
        return 0;
      }
    }
  }
  vector<int>::iterator it1, it2;
  for (i = 0; i <= n; i++) {
    it1 = f[i].begin();
    if (f[i + 1].empty()) break;
    it2 = f[i + 1].begin();
    while (it2 != f[i + 1].end()) {
      if (nr[*it1] < k) {
        sol.push_back(make_pair(*it1, *it2));
        nr[*it1]++;
        nr[*it2]++;
        it2++;
      } else
        it1++;
    }
  }
  printf("%d\n", sol.size());
  for (vector<pair<int, int> >::iterator it = sol.begin(); it != sol.end();
       it++)
    printf("%d %d\n", it->first, it->second);
  return 0;
}
