#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int maxn = 1008100;
vector<int> a[1000005];
vector<pair<int, int> > b;
int main() {
  long long n, m, k;
  cin >> n >> k;
  for (int i = 0; i <= n; i++) a[i].clear();
  b.clear();
  for (int i = 0; i < n; ++i) {
    int d;
    scanf("%d", &d);
    a[d].push_back(i);
  }
  if (a[0].size() != 1) {
    printf("-1\n");
    return 0;
  }
  int flag = 0;
  for (int i = 1; i < n; ++i) {
    if (a[i].size() > a[i - 1].size() * k) {
      flag = 1;
      break;
    }
    for (int j = 0; j < a[i].size(); ++j)
      b.push_back(make_pair(a[i][j], a[i - 1][j / k]));
    if (i == 1) --k;
  }
  if (flag)
    puts("-1");
  else {
    cout << b.size() << endl;
    for (int i = 0; i < b.size(); i++)
      printf("%d %d\n", b[i].first + 1, b[i].second + 1);
  }
  return 0;
}
