#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  vector<long long> vec[n + 1];
  long long arr[n];
  for (long long i = 0; i < n; i++) cin >> arr[i];
  for (long long i = 0; i < n; i++) {
    vec[arr[i]].push_back(i + 1);
  }
  if (vec[0].size() != 1) {
    cout << -1 << endl;
    return 0;
  }
  long long st = vec[0][1];
  queue<long long> que;
  long long dis = 0;
  vector<long long> gr[n + 1];
  long long z = 0;
  for (long long i = 1; i < n; i++) {
    long long c = 0;
    for (long long j = 0; j < vec[i].size(); ++j) {
      if (k == 0) {
        cout << -1 << endl;
        return 0;
      }
      if (vec[dis].size() == 0) {
        cout << -1 << endl;
        return 0;
      }
      gr[vec[dis][-1 + vec[dis].size()]].push_back(vec[i][j]);
      c = (c + 1);
      z++;
      if (c == k) {
        vec[dis].pop_back();
        c = 0;
      }
    }
    dis += 1;
    if (dis == 1) k--;
  }
  cout << z << endl;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 0; j < gr[i].size(); ++j) {
      cout << i << " " << gr[i][j] << endl;
    }
  }
}
