#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> d(n);
  map<int, int> mp;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    d[i] = {a, i + 1};
    mp[a]++;
  }
  sort(d.begin(), d.end());
  vector<long long int> graph[n + 1];
  if (mp[0] != 1) {
    cout << -1 << endl;
    return 0;
  }
  queue<pair<int, int>> q;
  q.push(d[0]);
  int idx = 1;
  while (!q.empty()) {
    pair<int, int> top = q.front();
    q.pop();
    if (idx == n) break;
    int last;
    if (top.first == 0)
      last = m;
    else
      last = m - 1;
    for (int i = 0; i < last; ++i) {
      if (idx == n) break;
      if (d[idx].first - top.first == 1) {
        graph[top.second].push_back(d[idx].second);
        q.push(d[idx]);
        idx++;
      } else
        break;
    }
  }
  if (idx != n) {
    cout << -1 << endl;
    return 0;
  }
  cout << n - 1 << endl;
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j < graph[i].size(); ++j) {
      cout << i << " " << graph[i][j] << endl;
    }
  }
  return 0;
}
