#include <bits/stdc++.h>
using namespace std;
vector<int> a[200200];
int N, K;
int check(int h) {
  if (a[0].size() != 1) return 0;
  if (a[1].size() > K) return 0;
  for (int i = 2; i <= h; i++) {
    int sz1 = a[i - 1].size();
    int sz2 = a[i].size();
    if ((long long)sz2 > (long long)sz1 * (K - 1)) return 0;
  }
  return 1;
}
int sz;
int main() {
  scanf("%d%d", &N, &K);
  for (int i = 0; i <= N; i++) a[i].clear();
  int m = N - 1;
  int h = 0;
  for (int i = 1; i <= N; i++) {
    int x;
    scanf("%d", &x);
    h = max(h, x);
    a[x].push_back(i);
  }
  if (!check(h))
    printf("-1\n");
  else {
    printf("%d\n", m);
    int pre = a[0][0];
    sz = a[1].size() - 1;
    for (int i = 0; i <= sz; i++) {
      printf("%d %d\n", pre, a[1][i]);
    }
    K--;
    for (int i = 2; i <= h; i++) {
      pre = 0;
      int sum = 0;
      int szz = a[i].size() - 1;
      for (int j = 0; j <= szz; j++) {
        int x = a[i][j];
        printf("%d %d\n", a[i - 1][pre], x);
        sum++;
        if (sum >= K) {
          sum = 0;
          pre++;
        }
      }
    }
  }
  return 0;
}
