#include <bits/stdc++.h>
using namespace std;
const long long int mod = 998244353;
long long int dx[] = {0, 0, 1, -1};
long long int dy[] = {1, -1, 0, 0};
long long int m = 1e9 + 9, n, res, k, ans = 0, nbcycle = 0, s;
long long int p = 31;
string s2 = "zero", ch = "";
set<long long int> st;
multiset<long long int> mst;
vector<pair<long long int, long long int> > vv, vv2, vm;
vector<pair<long long int, pair<long long int, long long int> > > vvv;
vector<pair<long long int, long long int> > vvs;
vector<long long int> v[100005], adj[100005];
long long int a[200005], vis[200005], dp[200005], red[200005];
map<pair<long long int, long long int>, long long int> mp;
void dfs(long long int x) {
  vis[x] = 1;
  for (long long int i = 0; i < adj[x].size(); i++) {
    long long int y = adj[x][i];
    if (!vis[y]) {
      dfs(y);
      vv.push_back({x, y});
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long int i = 0, x, y, j = 0, z, q, nb0 = 0, nbp = 0, nbn = 0, nbmax = 0,
                nbinf = 0, mm = 5e8, idx = 0, ok = 0, l = 0, r = 0, negatif = 0,
                positif = 0, l1, r1, d;
  set<long long int>::iterator it, it1;
  char c;
  cin >> n >> k;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    v[a[i]].push_back(i);
  }
  if (v[0].size() > 1 || !v[0].size()) return cout << "-1", 0;
  long long int node = v[0][0];
  for (i = 1; i <= n; i++) {
    if (!v[i].size()) break;
    long long int nb = v[i].size();
    if (i == 1 && v[i].size() > k)
      return cout << "-1", 0;
    else if (i > 1 && v[i - 1].size() * (k - 1) < nb) {
      return cout << "-1", 0;
    }
    z = 0;
    for (j = 0; j < v[i].size(); j++) {
      y = v[i - 1][z];
      if (adj[y].size() == k) z++;
      y = v[i - 1][z];
      x = v[i][j];
      adj[x].push_back(y);
      adj[y].push_back(x);
    }
  }
  memset(vis, 0, sizeof(vis));
  dfs(node);
  for (i = 1; i <= n; i++) {
    if (!vis[i]) return cout << "-1", 0;
  }
  cout << vv.size() << endl;
  for (i = 0; i < vv.size(); i++) {
    cout << vv[i].first << " " << vv[i].second << endl;
  }
  return 0;
}
