#include <bits/stdc++.h>
using namespace std;
set<pair<int, int> > second[100005];
vector<pair<int, int> > ans;
pair<int, int> ar[100005];
int main() {
  int n, k;
  scanf("%d", &n);
  scanf("%d", &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &ar[i].first);
    ar[i].second = i;
  }
  sort(ar + 1, ar + n + 1);
  if (ar[1].first != 0) {
    cout << "-1\n";
    return 0;
  }
  second[0].insert(make_pair(0, ar[1].second));
  int pos = 2;
  for (int i = 2; i <= n; i++) {
    if (ar[i].first == 0) {
      cout << "-1\n";
      return 0;
    }
    auto it = second[ar[i].first - 1].begin();
    if (it == second[ar[i].first - 1].end()) {
      cout << "-1\n";
      return 0;
    }
    pair<int, int> cur = *it;
    second[ar[i].first - 1].erase(it);
    ans.push_back(make_pair(cur.second, ar[i].second));
    if (cur.first < k - 1) {
      second[ar[i].first - 1].insert(make_pair(cur.first + 1, cur.second));
    }
    if (k != 1) {
      second[ar[i].first].insert(make_pair(1, ar[i].second));
    }
  }
  printf("%d", (int)ans.size());
  ;
  printf("\n");
  for (int i = 0; i <= (int)ans.size() - 1; i++) {
    printf("%d", ans[i].first);
    ;
    printf(" ");
    printf("%d", ans[i].second);
    ;
    printf("\n");
  }
  return 0;
}
