#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  long long start = -1;
  long long maxx = -1000;
  long long counter = 0;
  vector<pair<long long, long long>> k;
  vector<vector<long long>> g(n + 1);
  for (int i = 1; i < n + 1; i++) {
    long long u;
    cin >> u;
    if (u == 0) {
      if (start == -1) {
        start = i;
      } else {
        start = -100;
      }
    } else {
      if (g[u].size() == 0) counter++;
      g[u].push_back(i);
    }
    if (u > maxx) {
      maxx = u;
    }
  }
  if (start == -100 || start == -1 || counter != maxx) {
    cout << -1;
    return 0;
  } else {
    long long i = 1;
    if (m >= g[i].size()) {
      for (auto child : g[i]) {
        k.push_back(make_pair(start, child));
      }
    } else {
      cout << -1;
      return 0;
    }
    i++;
    while (i < maxx + 1) {
      long long s = g[i - 1].size();
      long long s1 = g[i].size();
      if (m * s >= s1 + 1) {
        long long j = 0;
        for (auto child : g[i]) {
          k.push_back(make_pair(g[i - 1][j], child));
          j = (j + 1) % g[i - 1].size();
        }
      } else {
        cout << -1;
        return 0;
      }
      i++;
    }
  }
  cout << k.size() << '\n';
  for (int i = 0; i < k.size(); i++) {
    cout << k[i].first << " " << k[i].second << '\n';
  }
  return 0;
}
