#include <bits/stdc++.h>
using namespace std;
const int inf = (int)2e9;
const int mod = (int)1e9 + 7;
const int maxn = (int)1e5 + 5;
const double eps = 1e-9;
const double pi = acos(-1.0);
struct edge {
  int id;
  int distance;
};
static bool compare(const edge& a, const edge& b) {
  return (a.distance < b.distance);
}
int n, k;
vector<int> g[maxn];
int main() {
  scanf("%d %d", &n, &k);
  vector<edge> a(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i].distance);
    a[i].id = i + 1;
  }
  sort(a.begin(), a.end(), compare);
  if (a[0].distance != 0) {
    printf("-1\n");
    return 0;
  }
  int it = 0;
  for (int i = 1; i < n; i++) {
    while (a[it].distance + 1 < a[i].distance or g[it].size() >= k) {
      it++;
    }
    if (a[it].distance + 1 != a[i].distance) {
      printf("-1\n");
      return 0;
    }
    g[it].push_back(i);
    g[i].push_back(it);
  }
  printf("%d\n", n - 1);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < (int)(g[i].size()); j++) {
      if (a[i].id < a[g[i][j]].id) {
        printf("%d %d\n", a[i].id, a[g[i][j]].id);
      }
    }
  }
  return 0;
}
