#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int N = 1000005;
const double PI = 4 * atan(1);
long long m, x, y, n, p, k, q, l, r;
vector<pair<long long, long long> > v, vv;
long long a[N];
long long many[N];
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> k;
  memset(a, -1, sizeof(a));
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    v.push_back(make_pair(a[i], i));
  }
  sort((v).begin(), (v).end());
  if (v[0].first != 0) {
    cout << -1;
    return 0;
  }
  long long j = 0;
  for (int i = 1; i < n; i++) {
    while (many[v[j].second] >= k || v[j].first < v[i].first - 1) {
      j++;
    }
    if (v[j].first == v[i].first) {
      cout << -1;
      return 0;
    }
    vv.push_back(make_pair(v[i].second, v[j].second));
    many[v[j].second]++;
    many[v[i].second]++;
  }
  if (vv.size() >= 1e6) {
    cout << -1;
    return 0;
  }
  cout << vv.size() << endl;
  for (auto t : vv) {
    cout << t.first + 1 << " " << t.second + 1 << endl;
  }
  return 0;
}
