#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MN = 2e5 + 7;
int n, m;
struct xy {
  int x, y;
} a[MN];
int du[MN];
vector<int> V[MN];
vector<xy> ans;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    int d;
    scanf("%d", &d);
    V[d].push_back(i);
  }
  if (V[0].size() != 1) {
    puts("-1");
    return 0;
  }
  int flag = 1;
  for (int i = 1; i <= n; i++) {
    int k = 0;
    for (int j = 0; j < V[i].size(); j++) {
      if (V[i - 1].size() == 0) {
        flag = 0;
        break;
      }
      int x = V[i - 1][k];
      int y = V[i][j];
      k = (k + 1) % V[i - 1].size();
      du[x]++;
      du[y]++;
      xy tmp;
      tmp.x = x;
      tmp.y = y;
      ans.push_back(tmp);
    }
  }
  if (V[0].size() != 1) flag = 0;
  for (int i = 1; i <= n; i++)
    if (du[i] > m) flag = 0;
  if (flag == 0) {
    puts("-1");
    return 0;
  }
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); i++) {
    printf("%d %d\n", ans[i].x, ans[i].y);
  }
  return 0;
}
