#include <bits/stdc++.h>
using namespace std;
template <class T>
inline std::string to_string(const T& t) {
  std::stringstream ss;
  ss << t;
  return ss.str();
}
int find_log(int n) {
  int log = 0;
  while (1) {
    if ((1 << log) > n) break;
    log++;
  }
  return log;
}
vector<int> ind[100005];
vector<int> inp;
vector<pair<int, int> > ans;
int f[100005], n, k, d, flag, t1, t2;
int deg[100005];
int main() {
  std::ios_base::sync_with_stdio(false);
  ;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> d;
    if (!f[d]) inp.push_back(d);
    f[d]++;
    ind[d].push_back(i);
  }
  if (n == 1) {
    if (inp[0] == 0)
      cout << "0" << endl;
    else
      cout << "-1" << endl;
  }
  sort(inp.begin(), inp.end());
  int s1 = inp.size();
  int loise = 0, g;
  if (inp[0] != 0) {
    cout << "-1" << endl;
    return 0;
  }
  if (f[inp[0]] > 1) {
    cout << "-1" << endl;
    return 0;
  }
  for (int j = 0; j <= s1 - 2; j++) {
    t1 = inp[j];
    t2 = inp[j + 1];
    if ((t2 - t1) != 1) {
      cout << "-1" << endl;
      return 0;
    }
    loise = 0, g = 0;
    for (int l1 = 0; l1 <= ind[t1].size() - 1; l1++) {
      for (int l2 = g; l2 <= ind[t2].size() - 1; l2++) {
        int p1 = ind[t1][l1];
        int p2 = ind[t2][l2];
        if (deg[p1] < k && deg[p2] < k) {
          ans.push_back(make_pair(p1, p2));
          deg[p1]++;
          deg[p2]++;
          g++;
        } else {
          break;
        }
      }
    }
    if (g < ind[t2].size()) {
      cout << "-1" << endl;
      return 0;
    }
  }
  int siz = ans.size();
  cout << siz << endl;
  for (int i = 0; i <= siz - 1; i++) {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
}
