#include <bits/stdc++.h>
using namespace std;
int const N = 1e5 + 10;
int n, k, d[N], root, dist[N];
vector<pair<int, int> > ans;
set<int> D[N];
bool mrk[N];
vector<int> adj[N];
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> d[i], D[d[i]].insert(i);
  if (D[0].size() != 1) {
    cout << "-1" << '\n';
    return 0;
  }
  queue<int> bfs;
  root = *D[0].begin();
  bfs.push(root);
  mrk[root] = true;
  while (!bfs.empty()) {
    int v = bfs.front();
    bfs.pop();
    int dis = d[v] + 1, sz = k - 1;
    if (v == root) sz++;
    for (int i = 1; i <= sz; i++) {
      if (D[dis].empty()) break;
      adj[v].push_back(*D[dis].begin());
      ans.push_back(pair<int, int>(v, *D[dis].begin()));
      bfs.push(*D[dis].begin());
      mrk[*D[dis].begin()] = true;
      D[dis].erase(D[dis].begin());
    }
  }
  memset(dist, -1, sizeof(dist));
  bfs.push(root);
  dist[root] = 0;
  while (!bfs.empty()) {
    int v = bfs.front();
    bfs.pop();
    for (auto i : adj[v])
      if (dist[i] == -1 || dist[i] > dist[v] + 1)
        dist[i] = dist[v] + 1, bfs.push(i);
  }
  for (int i = 1; i <= n; i++)
    if (d[i] != dist[i]) {
      cout << "-1" << '\n';
      return 0;
    }
  cout << ans.size() << '\n';
  for (auto i : ans) cout << i.first << " " << i.second << '\n';
  return 0;
}
