#include <bits/stdc++.h>
using namespace std;
template <class T>
T min(const T& a, const T& b, const T& c) {
  return min(min(a, b), min(a, c));
}
template <class T>
T max(const T& a, const T& b, const T& c) {
  return max(max(a, b), max(a, c));
}
void debug() {}
int getch() {
  int ch;
  while ((ch = getchar()) != EOF) {
    if (ch != ' ' && ch != '\n') return ch;
  }
  return EOF;
}
struct Edge {
  int u, v;
};
const int maxn = 101000;
vector<int> x[maxn];
vector<Edge> E;
int main() {
  int n, k;
  while (scanf("%d%d", &n, &k) != EOF) {
    E.clear();
    for (int i = 0; i <= n; i++) x[i].clear();
    int maxd = 0;
    for (int i = 1; i <= n; i++) {
      int d;
      scanf("%d", &d);
      x[d].push_back(i);
      maxd = max(maxd, d);
    }
    if (x[0].size() != 1)
      printf("-1\n");
    else {
      int flag = 1;
      for (int i = 1; i <= maxd; i++) {
        if (x[i].size() > (long long)x[i - 1].size() * (i == 1 ? k : (k - 1))) {
          flag = 0;
          break;
        }
        for (int j = 0, s = 0, c = 0; j < x[i].size(); j++) {
          E.push_back((Edge){x[i - 1][s], x[i][j]});
          c++;
          if (c == (i == 1 ? k : (k - 1))) {
            s++;
            c = 0;
          }
        }
      }
      if (!flag)
        printf("-1\n");
      else {
        printf("%d\n", E.size());
        for (int i = 0; i < E.size(); i++) printf("%d %d\n", E[i].u, E[i].v);
      }
    }
  }
  return 0;
}
