#include <bits/stdc++.h>
const int N = 100100;
using namespace std;
int n, k, c[N], d[N];
vector<pair<int, int> > v, g;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> k;
  int root = -1;
  for (int i = 1; i <= n; i++) {
    cin >> d[i];
    if (d[i] == 0) {
      if (root == -1)
        root = i;
      else {
        cout << -1 << endl;
        return 0;
      }
    } else
      g.push_back({d[i], i});
  }
  if (root == -1) {
    cout << -1 << endl;
    return 0;
  }
  g.push_back({0, root});
  sort(g.begin(), g.end());
  int j = 0;
  for (int i = 1; i < g.size(); i++) {
    while (c[j] == k || g[j].first + 1 < g[i].first) j++;
    if (g[j].first + 1 != g[i].first) {
      cout << -1 << endl;
      return 0;
    }
    c[j]++;
    c[i]++;
    v.push_back({g[j].second, g[i].second});
  }
  cout << v.size() << endl;
  for (int i = 0; i < v.size(); i++)
    cout << v[i].first << " " << v[i].second << endl;
}
