#include <bits/stdc++.h>
using namespace std;
int deg[100005];
vector<int> gr[100005];
vector<pair<int, int> > pp;
pair<int, int> p;
struct node {
  int u, w;
  node(int a, int b) {
    u = a;
    w = b;
  }
  bool operator<(const node &p) const { return p.w < w; }
};
priority_queue<node> ans[100005];
int main() {
  int n, k, i, u, v, j, sz;
  cin >> n >> k;
  for (i = 1; i <= n; i++) {
    cin >> u;
    ans[u].push(node(i, 0));
    gr[u].push_back(i);
  }
  if (gr[0].size() != 1) {
    cout << "-1" << endl;
    return 0;
  }
  for (i = 1; i <= n; i++) {
    if (gr[i].size() > 0) {
      if (ans[i - 1].size() == 0) {
        cout << "-1" << endl;
        return 0;
      }
      sz = gr[i].size();
      for (j = 0; j < sz; j++) {
        node top = ans[i - 1].top();
        ans[i - 1].pop();
        deg[top.u]++;
        ans[i - 1].push(node(top.u, top.w + 1));
        node top1 = ans[i].top();
        ans[i].pop();
        deg[top1.u]++;
        ans[i].push(node(top1.u, top1.w + 1));
        pp.push_back(make_pair(top.u, top1.u));
      }
    }
  }
  for (i = 1; i <= n; i++) {
    if (deg[i] > k) {
      cout << -1 << endl;
      return 0;
    }
  }
  sz = pp.size();
  cout << sz << endl;
  for (i = 0; i < sz; i++) {
    p = pp[i];
    cout << p.first << " " << p.second << endl;
  }
  return 0;
}
