#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
struct node {
  int dist, ind;
  node() {}
  node(int ind, int dist) : ind(ind), dist(dist) {}
};
node arr[MAXN];
bool cmp(const node& a, const node& b) { return a.dist < b.dist; }
vector<int> level[MAXN];
bool operator<(const node& a, const node& b) { return a.dist > b.dist; }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  int mx_level = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i].dist;
    arr[i].ind = i;
    mx_level = max(arr[i].dist, mx_level);
  }
  sort(arr, arr + n, cmp);
  if (arr[0].dist || arr[0].dist == arr[1].dist) {
    cout << "-1\n";
    return 0;
  }
  for (int i = 0; i < n; i++) {
    level[arr[i].dist].push_back(arr[i].ind);
  }
  priority_queue<node> pq;
  vector<pair<int, int> > res;
  pq.push(arr[0]);
  level[0].pop_back();
  node temp, cur;
  while (!pq.empty()) {
    cur = pq.top();
    pq.pop();
    int v = cur.ind;
    int lvl = cur.dist;
    int nlvl = cur.dist + 1;
    int K = k - 1;
    if (!lvl) K++;
    for (int i = 0; i < K && !level[nlvl].empty(); i++) {
      int child = level[nlvl].back();
      level[nlvl].pop_back();
      pq.push(node(child, nlvl));
      res.push_back(make_pair(v + 1, child + 1));
    }
  }
  for (int i = 0; i <= mx_level; i++)
    if (!level[i].empty()) {
      cout << "-1\n";
      return 0;
    }
  cout << (int)res.size() << "\n";
  for (int i = 0; i < (int)res.size(); i++)
    cout << res[i].first << " " << res[i].second << "\n";
  return 0;
}
