#include <bits/stdc++.h>
using namespace std;
int n, k, mx, vis[100005];
int main() {
  cin >> n >> k;
  deque<int> q[n];
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    mx = max(a[i], mx);
    q[a[i]].push_back(i + 1);
  }
  vector<pair<int, int>> p;
  if (q[0].size() != 1) {
    return cout << -1, 0;
  }
  if (k > 1) {
    int o = q[mx].size();
    for (int i = 0; i < o - 1; i++) {
      q[mx].push_back(q[mx].front());
      q[mx].pop_front();
      p.push_back(
          {min(q[mx].front(), q[mx].back()), max(q[mx].back(), q[mx].front())});
    }
  }
  k -= 1;
  for (int i = mx - 1; i >= 0; i--) {
    if (i == 0) k++;
    if (q[i + 1].size() > q[i].size() * (k) && (i != mx - 1)) {
      return cout << -1, 0;
    }
    if (i == mx - 1 && k == 0 && q[i + 1].size() > q[i].size() * (k))
      return cout << -1, 0;
    int u = q[i + 1].size();
    int v = q[i].size();
    if (!(u && v)) return cout << -1, 0;
    int g = ceil((double)u / (double)v);
    while (q[i + 1].size() > 0) {
      int z = g;
      while (z--) {
        if (q[i + 1].size() == 0) break;
        p.push_back({min(q[i + 1].front(), q[i].front()),
                     max(q[i + 1].front(), q[i].front())});
        q[i + 1].pop_front();
      }
      q[i].push_back(q[i].front());
      q[i].pop_front();
    }
  }
  sort(p.begin(), p.end());
  cout << p.size() << endl;
  for (auto i : p) cout << i.first << " " << i.second << endl;
}
