#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long no_of_vertex, max_edge;
  long long input;
  cin >> no_of_vertex >> max_edge;
  vector<long long> adj[100005];
  for (long long i = 1; i <= no_of_vertex; i++) {
    cin >> input;
    adj[input].push_back(i);
  }
  if (adj[0].size() != 1) {
    cout << -1;
    return 0;
  }
  vector<pair<long long, long long> > ans;
  for (long long i = 1; i < 100005; i++) {
    if (adj[i - 1].size() * (max_edge - (i - 1 != 0)) < adj[i].size()) {
      cout << -1;
      return 0;
    }
    reverse(adj[i - 1].begin(), adj[i - 1].end());
    long long pos = 0;
    for (long long j = 0; j < adj[i].size(); j++) {
      if (pos < adj[i - 1].size()) {
        ans.push_back({adj[i - 1][pos], adj[i][j]});
        pos++;
      } else {
        j--;
        pos = 0;
      }
    }
  }
  cout << ans.size() << "\n";
  for (auto k : ans) {
    cout << k.first << " " << k.second << "\n";
  }
}
