#include <bits/stdc++.h>
using namespace std;
template <typename... T>
void read(T&... args) {
  ((cin >> args), ...);
}
template <typename... T>
void write(T&&... args) {
  ((cout << args << " "), ...);
}
using namespace std;
long long int __gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return __gcd(b, a % b);
}
void solve() {
  long long int n, k;
  read(n, k);
  pair<long long int, long long int> arr[n];
  map<long long int, long long int> mp1;
  for (long long int i = 0; i < n; i++) {
    cin >> arr[i].first;
    mp1[arr[i].first]++;
    arr[i].second = i + 1;
  }
  sort(arr, arr + n);
  if (mp1[0] == 0 || mp1[0] > 1) {
    cout << -1 << endl;
    return;
  }
  vector<pair<long long int, long long int> > ans;
  vector<long long int> arr1;
  arr1.push_back(arr[0].second);
  long long int cnt = 1, start = 1, latest = 0, p = 0, flag = 0;
  long long int start1 = 0, start2 = 1, sum = 0;
  while (start1 <= start2) {
    if (sum == k) {
      start1++;
      if (arr[start1].first == arr[start2].first) break;
      sum = 0;
    }
    ans.push_back(make_pair(arr[start1].second, arr[start2].second));
    start2++;
    if (start2 == n) break;
    if (arr[start2].first - arr[start2 - 1].first > 1) break;
    sum++;
    if (arr[start2].first - arr[start2 - 1].first == 1) {
      sum = 0;
      while (arr[start1].first != arr[start2].first - 1) start1++;
    }
    if (arr[start2].first != 1 && flag == 0) k--, flag = 1;
  }
  if (start2 == n) {
    cout << ans.size() << endl;
    for (long long int i = 0; i < ans.size(); i++)
      cout << ans[i].first << " " << ans[i].second << endl;
  } else {
    cout << -1 << endl;
  }
}
int main() {
  int t;
  t = 1;
  ;
  while (t--) {
    solve();
  }
}
