#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k, i, x;
  queue<long long int> q1;
  vector<pair<long long int, long long int> > v1;
  vector<pair<long long int, long long int> > fin;
  vector<long long int> degree;
  long long int flag, count1, j1, y1, j, y;
  cin >> n >> k;
  degree.push_back(0);
  for (i = 0; i < n; i++) {
    cin >> x;
    v1.push_back(make_pair(x, i + 1));
    degree.push_back(0);
  }
  sort(v1.begin(), v1.end());
  q1.push(0);
  if ((v1[0].first) != 0)
    cout << "-1" << endl;
  else {
    j = 1;
    flag = 0;
    count1 = 0;
    while (j <= n - 1) {
      y1 = q1.front();
      x = v1[j].first;
      y = v1[y1].first;
      if ((x - y) == 1) {
        if (degree[v1[y1].second] >= k || degree[v1[j].second] >= k) {
          if (!q1.empty()) q1.pop();
          if (q1.empty()) {
            flag = 1;
            break;
          }
        } else {
          degree[v1[y1].second]++;
          degree[v1[j].second]++;
          count1++;
          q1.push(j);
          fin.push_back(make_pair(v1[y1].second, v1[j].second));
          j++;
        }
      } else if ((x - y) == 0) {
        flag = 1;
        break;
      } else {
        if (!q1.empty()) q1.pop();
        if (q1.empty()) {
          flag = 1;
          break;
        }
      }
    }
    if (flag == 1)
      cout << "-1" << endl;
    else {
      cout << count1 << endl;
      for (j = 0; j < fin.size(); j++)
        cout << fin[j].first << " " << fin[j].second << endl;
    }
  }
  return 0;
}
