#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
void solve() {
  int n, k;
  cin >> n >> k;
  vector<vector<int>> Adj(n);
  vector<pair<int, int>> atDist(n);
  for (int i = 0; i < n; ++i) {
    cin >> atDist[i].first;
    atDist[i].second = i;
  }
  sort(atDist.begin(), atDist.end());
  priority_queue<pair<int, int>, vector<pair<int, int>>,
                 greater<pair<int, int>>>
      Heap;
  vector<queue<int>> Q(n);
  int root = -1;
  for (int i = 0; i < n; ++i) {
    Heap.push(atDist[i]);
    Q[atDist[i].first].push(atDist[i].second);
    if (atDist[i].first == 0) {
      if (root != -1) {
        cout << -1 << '\n';
        return;
      }
      root = atDist[i].second;
    }
  }
  if ((max_element(atDist.begin(), atDist.end())->first) > 1 && k == 1) {
    cout << -1 << '\n';
    return;
  }
  int e = 0;
  while (!Heap.empty()) {
    auto top = Heap.top();
    Heap.pop();
    int level = top.first;
    int index = top.second;
    if (level == 0) continue;
    if (Q[level - 1].empty()) {
      cout << -1 << '\n';
      return;
    }
    int index2 = Q[level - 1].front();
    Q[level - 1].pop();
    ++e;
    Adj[index].push_back(index2);
    Adj[index2].push_back(index);
    if (Adj[index2].size() < k) Q[level - 1].push(index2);
  }
  cout << e << '\n';
  for (int i = 0; i < n; ++i)
    for (int j : Adj[i]) {
      if (i < j) cout << i + 1 << ' ' << j + 1 << '\n';
    }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  while (t--) {
    solve();
    ;
  }
  return 0;
}
