#include <bits/stdc++.h>
using namespace std;
vector<int> v[100005];
int d[100005];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    v[x].push_back(i);
  }
  int temp = v[0].size();
  int sum = temp, depth = 0;
  if (temp != 1) {
    printf("-1\n");
    return 0;
  }
  for (int i = 1; i < 100005; i++) {
    int x = v[i].size();
    long long int y = (long long)temp * k - temp;
    if (i == 1) y++;
    if (y < x || x == 0) {
      printf("-1\n");
      return 0;
    }
    temp = x;
    sum += x;
    if (sum == n) {
      depth = i;
      break;
    }
  }
  printf("%d\n", n - 1);
  for (int i = 0; i < 100005; i++) {
    int x = 0;
    int ans1, ans2;
    for (int j = 0; j < v[i + 1].size(); j++) {
      ans2 = v[i + 1][j];
      ans1 = v[i][x];
      x++;
      if (x == v[i].size()) {
        x = 0;
      }
      printf("%d %d\n", ans1, ans2);
    }
  }
  return 0;
}
