#include <bits/stdc++.h>
using namespace std;
struct Node {
  int Pos, Dist;
  bool operator<(Node b) const { return Dist < b.Dist; }
};
Node graph[100010];
class Solution {
 public:
  void RecoverGraph(int Dist[], int n, int k) {
    for (int i = 0; i < n; i++) {
      graph[i].Pos = i + 1;
      graph[i].Dist = Dist[i];
    }
    sort(graph, graph + n);
    if (graph[0].Dist != 0) {
      printf("-1\n");
      return;
    }
    int cur = 0, h = 0;
    int kk = k;
    int u = 1;
    while (h < n) {
      if ((h > 0) && (graph[h].Dist - 1 != graph[h - 1].Dist)) {
        printf("-1\n");
        return;
      }
      int temp = 1;
      while ((h + 1 < n) && (graph[h].Dist == graph[h + 1].Dist)) {
        h++;
        temp++;
      }
      if (cur == 0) {
        if (temp != 1) {
          printf("-1\n");
          return;
        }
        cur = temp;
      } else if ((long long)temp > (long long)cur * (long long)k -
                                       (long long)cur + (long long)u) {
        printf("-1\n");
        return;
      } else
        cur = temp;
      if (graph[h].Dist == 1) u--;
      h++;
    }
    int last = 0;
    h = 1;
    printf("%d\n", n - 1);
    while (h < n) {
      int hh = h;
      while ((h + 1 < n) && (graph[h].Dist == graph[h + 1].Dist)) h++;
      int tot = 0;
      if (last == 0)
        tot = 0;
      else
        tot = 1;
      for (int i = hh; i <= h; i++) {
        printf("%d %d\n", graph[i].Pos, graph[last].Pos);
        tot++;
        if (tot == k) {
          if (last == 0)
            tot = 0;
          else
            tot = 1;
          last++;
        }
      }
      last = hh;
      h++;
    }
  }
};
int dist[100000];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) scanf("%d", &dist[i]);
  Solution ans;
  ans.RecoverGraph(dist, n, k);
  return 0;
}
