#include <bits/stdc++.h>
using namespace std;
long long arr[100010];
vector<pair<long long, long long>> ans;
vector<long long> dis[100010];
signed main() {
  long long n, k;
  long long d;
  cin >> n >> k;
  for (long long i = 1; i <= n; i++) {
    cin >> d;
    dis[d].push_back(i);
  }
  if (dis[0].size() != 1) {
    cout << "-1";
    return 0;
  } else {
    for (long long i = 1; i <= n - 1; i++) {
      if (dis[i].size() > dis[i - 1].size() * k) {
        cout << "-1";
        return 0;
      } else {
        for (long long j = 0; j < dis[i].size(); j++) {
          ans.push_back(make_pair(dis[i][j], dis[i - 1][j / k]));
        }
        if (i == 1) {
          k--;
        }
      }
    }
    cout << ans.size() << endl;
    for (long long i = 0; i < ans.size(); i++) {
      cout << ans[i].first << " " << ans[i].second << endl;
    }
  }
}
