#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const double PI = acos(-1.0);
const int N = 1e5 + 7;
bitset<N> us;
int dp[N];
int cnt[N];
pair<int, int> ma[N];
int num[N];
int b[N], e[N];
int s;
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &ma[i].first);
    ma[i].second = i;
  }
  sort(ma, ma + n);
  if (ma[0].first || !ma[1].first) return puts("-1"), 0;
  fill_n(num, N, N);
  for (int i = 0; i < n; i++) num[ma[i].first] = min(i, num[ma[i].first]);
  for (int i = 0; i < n; i++) {
    int l = num[ma[i].first + 1];
    int tmp = l + dp[l];
    if (ma[l].first - ma[i].first == 1)
      for (int j = tmp; ma[j].first == ma[i].first + 1 && j < n && j - tmp <= k;
           j++) {
        int u = ma[j].second;
        int v = ma[i].second;
        if (cnt[u] < k && cnt[v] < k) {
          us[u] = 1;
          us[v] = 1;
          cnt[u]++;
          cnt[v]++;
          b[s] = v;
          e[s++] = u;
          dp[l]++;
        }
      }
  }
  if (s < n - 1) return puts("-1"), 0;
  cout << s << endl;
  for (int i = 0; i < s; i++) printf("%d %d\n", b[i] + 1, e[i] + 1);
  return 0;
}
