#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> v[100010];
struct node {
  int a, b;
} ans[1000010];
int vis[100010];
int maxn;
bool deal() {
  int len = 0;
  if (v[0].size() != 1) return 1;
  if (v[1].size() > m) return 1;
  for (int i = 1; i <= maxn; i++) {
    if (v[i].size() == 0) return 1;
    int pre = 0;
    for (int j = 0; j < v[i].size(); j++) {
      if (vis[v[i - 1][pre]] == m) pre++;
      if (pre >= v[i - 1].size()) return 1;
      vis[v[i - 1][pre]]++;
      vis[v[i][j]]++;
      ans[len].a = v[i - 1][pre];
      ans[len].b = v[i][j];
      len++;
    }
  }
  printf("%d\n", len);
  for (int i = 0; i < len; i++) printf("%d %d\n", ans[i].a, ans[i].b);
  return 0;
}
int main() {
  while (~scanf("%d%d", &n, &m)) {
    for (int i = 0; i <= n; i++) v[i].clear();
    int dis;
    maxn = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &dis);
      maxn = max(maxn, dis);
      v[dis].push_back(i);
    }
    memset(vis, 0, sizeof(vis));
    if (deal()) printf("-1\n");
  }
  return 0;
}
