#include <bits/stdc++.h>
using namespace std;
long long int n, k, tmp;
vector<long long int> arr[(long long int)1000002];
vector<long long int> adj[(long long int)1000002];
long long int na[(long long int)1000002];
int main() {
  cin >> n >> k;
  for (long long int i = 0; i < n; i++) {
    cin >> tmp;
    arr[tmp].push_back(i);
  }
  bool f = (long long int)arr[0].size() == 1;
  long long int tp = 1;
  for (long long int i = 1; i < n; i++) {
    if ((long long int)arr[i].size() == 0 || !f) break;
    long long int pi = 0;
    for (long long int j = 0; j < (long long int)arr[i].size(); j++) {
      while (pi < n && na[arr[i - 1][pi]] == k) pi++;
      if (pi == (long long int)arr[i - 1].size()) {
        f = 0;
        break;
      }
      na[arr[i - 1][pi]]++;
      na[arr[i][j]]++;
      tp++;
      adj[min(arr[i - 1][pi], arr[i][j])].push_back(
          max(arr[i - 1][pi], arr[i][j]));
    }
  }
  if (tp != n) f = 0;
  if (!f) {
    cout << -1;
  } else {
    cout << n - 1 << endl;
    for (long long int i = 0; i < n; i++)
      for (long long int j = 0; j < (long long int)adj[i].size(); j++) {
        cout << i + 1 << " " << adj[i][j] + 1 << endl;
      }
  }
}
