#include <bits/stdc++.h>
using namespace std;
int n, k, q[100005];
pair<int, int> a[100005];
vector<int> v[100005];
vector<pair<int, int> > d;
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i].first, a[i].second = i;
  sort(a + 1, a + 1 + n);
  if ((!a[1].first && !a[2].first) || (a[1].first)) {
    cout << -1 << endl;
    return 0;
  }
  int tmp = a[1].first;
  for (int i = 1; i <= n; i++)
    if (a[i].first == tmp)
      v[tmp].push_back(i);
    else if (a[i].first > tmp && a[i].first - tmp > 1) {
      cout << -1 << endl;
      return 0;
    } else if (a[i].first > tmp && a[i].first - tmp == 1)
      tmp = a[i].first, v[tmp].push_back(i);
  for (int i = 1; i <= tmp; i++) {
    int second = 0;
    for (int j = 0; j < v[i].size(); j++)
      if (q[v[i - 1][second]] + 1 <= k)
        d.push_back(make_pair(a[v[i - 1][second]].second, a[v[i][j]].second)),
            q[v[i - 1][second]]++, q[v[i][j]]++;
      else if (q[v[i - 1][second]] + 1 >= k && second + 1 < v[i - 1].size())
        q[v[i - 1][++second]]++, q[v[i][j]]++,
            d.push_back(
                make_pair(a[v[i - 1][second]].second, a[v[i][j]].second));
      else {
        cout << -1 << endl;
        return 0;
      }
  }
  cout << d.size() << endl;
  for (int i = 0; i < d.size(); i++)
    cout << d[i].first << " " << d[i].second << endl;
  return 0;
}
