#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int dr8[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dc8[] = {1, -1, 0, 0, -1, 1, -1, 1};
int dr4[] = {0, 1, -1, 0};
int dc4[] = {1, 0, 0, -1};
map<int, set<pair<int, int> > > m;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, k;
  cin >> n >> k;
  int a[n + 1];
  vector<pair<int, int> > ar;
  ar.push_back(make_pair(0, 0));
  int v = -1;
  int np = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i + 1];
    ar.push_back(make_pair(a[i + 1], i + 1));
    if (v == -1 && a[i + 1] == 0) {
      v = i + 1;
    } else if (v != -1 && a[i + 1] == 0) {
      np = 1;
    }
  }
  if (np == 1 || v == -1) {
    cout << -1;
    return 0;
  }
  sort(ar.begin(), ar.end());
  vector<pair<int, int> > vv;
  m[0].insert(make_pair(0, v));
  for (int i = 1; i <= n; i++) {
    if (ar[i].first == 0) continue;
    if (m[ar[i].first - 1].empty()) {
      np = 1;
      break;
    }
    int in = (*m[ar[i].first - 1].begin()).second;
    int ed = (*m[ar[i].first - 1].begin()).first;
    vv.push_back(make_pair(ar[i].second, in));
    if (ed == k - 1) {
      m[ar[i].first - 1].erase(m[ar[i].first - 1].begin());
    } else {
      m[ar[i].first - 1].erase(m[ar[i].first - 1].begin());
      m[ar[i].first - 1].insert(make_pair(ed + 1, in));
    }
    if (k != 1) m[ar[i].first].insert(make_pair(1, ar[i].second));
  }
  if (np == 1) {
    cout << -1;
    return 0;
  }
  int sz = vv.size();
  cout << sz << "\n";
  for (int i = 0; i < sz; i++) {
    cout << vv[i].first << " " << vv[i].second << "\n";
  }
}
