#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<pair<int, int>> distance;
  for (int i = 0; i < n; i++) {
    int v;
    cin >> v;
    distance.push_back(make_pair(v, i + 1));
  }
  sort(distance.begin(), distance.end());
  vector<vector<pair<int, int>>> queu;
  vector<int> from(n + 1, -1);
  vector<pair<int, int>> ligne;
  queu.push_back(ligne);
  if (distance[0].first != 0) {
    cout << "-1" << endl;
    return 0;
  }
  queu[0].push_back(make_pair(0, distance[0].second));
  for (int i = 1; i < distance.size(); i++) {
    int dist = distance[i].first;
    if (dist <= 0 || dist > queu.size()) {
      cout << "-1" << endl;
      return 0;
    }
    if (queu[dist - 1].empty()) {
      cout << "-1" << endl;
      return 0;
    }
    ++queu[dist - 1].back().first;
    from[distance[i].second] = queu[dist - 1].back().second;
    if (queu[dist - 1].back().first >= k) queu[dist - 1].pop_back();
    if (queu.size() <= dist) {
      vector<pair<int, int>> ligne;
      queu.push_back(ligne);
    }
    if (1 < k) queu[dist].push_back(make_pair(1, distance[i].second));
  }
  cout << n - 1 << "\n";
  for (int i = 1; i <= n; i++) {
    if (from[i] > 0) {
      cout << i << " " << from[i] << "\n";
    }
  }
}
