#include <bits/stdc++.h>
using namespace std;
bool dbg = 0;
int N, K;
vector<vector<int> > Distance;
set<int> inp;
vector<vector<int> > Edges;
int degree[100005];
int main() {
  cin >> N >> K;
  int x, y;
  int Count = 0;
  Distance.resize(2 * N + 5);
  for (int n = 0; n < N; ++n) {
    scanf("%d", &x);
    inp.insert(x);
    Distance[x].push_back(n + 1);
  }
  if (Distance[0].size() != 1) {
    cout << -1 << endl;
    return 0;
  }
  Edges.resize(N + 5);
  set<int>::iterator it1;
  set<int>::iterator it2;
  it1 = inp.begin();
  ++it1;
  while (it1 != inp.end()) {
    it2 = it1;
    --it2;
    if (dbg) {
      cout << *it2 << " " << *it1 << endl;
    }
    if (*it1 - 1 != *it2) {
      cout << -1 << endl;
      return 0;
    }
    int Pos = 0;
    for (int n = 0; n < Distance[*it1].size(); ++n) {
      if (dbg) {
        cout << "  " << Distance[*it1][n] << " " << Pos << " "
             << Distance[*it2][Pos] << " " << degree[Distance[*it2][Pos]]
             << endl;
      }
      if (degree[Distance[*it2][Pos]] < K) {
        degree[Distance[*it2][Pos]]++;
        degree[Distance[*it1][n]]++;
        Count++;
        Edges[Distance[*it2][Pos]].push_back(Distance[*it1][n]);
      } else {
        Pos++;
        --n;
        if (Pos >= Distance[*it2].size()) {
          cout << -1 << endl;
          return 0;
        }
        if (dbg) {
          cout << "       " << Distance[*it2].size() << endl;
        }
      }
    }
    ++it1;
  }
  cout << Count << endl;
  for (int n = 1; n <= N; ++n) {
    if (Edges[n].size() > 0) {
      for (int m = 0; m < Edges[n].size(); ++m) {
        printf("%d %d\n", n, Edges[n][m]);
      }
    }
  }
  return 0;
}
