#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, k;
  scanf("%d%d", &n, &k);
  map<int, vector<int>> m;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    m[x].push_back(i);
  }
  if (m[0].size() != 1) {
    puts("-1");
    return;
  }
  vector<pair<int, int>> ans;
  vector<pair<int, vector<int>>> a;
  a.assign(m.begin(), m.end());
  for (int rep = 0; rep < a.size() - 1; rep++) {
    if (rep == 1) k--;
    if (a[rep].first + 1 != a[rep + 1].first) {
      puts("-1");
      return;
    }
    vector<int> vertices = a[rep + 1].second;
    long long val = 0;
    for (int i = 0; i < a[rep].second.size(); i++) {
      for (long long j = val;
           j < min(val + k, (long long)a[rep + 1].second.size()); j++) {
        ans.push_back({a[rep].second[i], a[rep + 1].second[j]});
      }
      val += k;
    }
    if (val < a[rep + 1].second.size()) {
      puts("-1");
      return;
    }
  }
  printf("%d\n", ans.size());
  for (auto x : ans) {
    printf("%d %d\n", x.first + 1, x.second + 1);
  }
}
int main() {
  int t = 1;
  while (t--) solve();
  return 0;
}
