#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<pair<int, int> > v;
  map<int, vector<int> > mp;
  for (int i = 1; i <= n; i++) {
    int l;
    cin >> l;
    v.push_back({l, i});
    mp[l].push_back(i);
  }
  sort(v.begin(), v.end());
  vector<int> a(n + 1, k);
  if (v[0].first != 0) {
    cout << "-1";
    return 0;
  }
  int in = v[0].second;
  int j = 0, i = 1;
  vector<pair<int, int> > ans;
  while (i < n && j < n) {
    if (v[j].first + 1 == v[i].first && a[v[j].second] > 0 &&
        a[v[i].second] > 0) {
      ans.push_back({v[j].second, v[i].second});
      a[v[j].second]--;
      a[v[i].second]--;
      i++;
    } else
      j++;
  }
  if (i != n)
    cout << "-1" << endl;
  else {
    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); i++)
      cout << ans[i].first << " " << ans[i].second << endl;
  }
  return 0;
}
