#include <bits/stdc++.h>
using namespace std;
int inf = INT_MAX >> 1;
long long linf = 1e18, lninf = -1e18;
long long mod = 1e9 + 7;
double PI = 3.1415926535897932384626433832795;
double eps = 1e-12;
const int N = 1e5 + 5;
vector<int> v[N];
pair<int, int> pr[N];
int src, res;
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 0, a; i < n; i++) {
    scanf("%d", &a);
    v[a].push_back(i);
  }
  long long temp = k;
  for (int i = 1; i < n; i++) {
    if (temp < v[i].size() || v[0].size() > 1) {
      puts("-1");
      return 0;
    }
    temp = (long long)v[i].size() * k - v[i].size();
  }
  if (v[0].size() == 0) {
    puts("-1");
    return 0;
  }
  for (int i = 0; i < n - 1; i++) {
    int cnt = 0, idx = 0;
    if (i != 0) cnt++;
    for (int j = 0; j < v[i + 1].size(); j++) {
      pr[res++] = make_pair(v[i][idx], v[i + 1][j]);
      cnt++;
      if (cnt == k) {
        cnt = 0;
        idx++;
        if (i != 0) cnt++;
      }
    }
  }
  cout << res << '\n';
  for (int i = 0; i < res; i++) {
    cout << pr[i].first + 1 << ' ' << pr[i].second + 1 << '\n';
  }
  return 0;
}
