#include <bits/stdc++.h>
using namespace std;
struct point {
  int x, y;
  point() {}
  point(int a, int b) { x = a, y = b; }
};
template <class T>
T sqr(T a) {
  return a * a;
}
template <class T>
T power(T n, T p) {
  T res = 1;
  for (int i = 0; i < p; i++) res *= n;
  return res;
}
template <class T>
double getdist(T a, T b) {
  return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
template <class T>
T extract(string s, T ret) {
  stringstream ss(s);
  ss >> ret;
  return ret;
}
template <class T>
string tostring(T n) {
  stringstream ss;
  ss << n;
  return ss.str();
}
template <class T>
inline T Mod(T n, T m) {
  return (n % m + m) % m;
}
template <class T>
void print_all(T v) {
  for (int i = 0; i < v.size(); i++) cout << v[i] << ' ';
};
template <class T>
void print_all(T &v, int len) {
  for (int i = 0; i < len; i++) cout << v[i] << ' ';
}
template <class T>
void print_pair(T v, int len) {
  for (int i = 0; i < len; i++)
    cout << v[i].first << ' ' << v[i].second << endl;
}
struct node {
  int indx, adj, dist;
};
queue<int> Q;
node arr[100010];
bool comp(const node &a, const node &b) { return a.dist < b.dist; }
vector<pair<int, int> > ans;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, i, k, gone, cur;
  cin >> n >> k;
  for (i = 1; i <= n; i++) {
    cin >> arr[i].dist;
    arr[i].indx = i;
    if (arr[i].dist == 0) Q.push(1);
  }
  if (Q.size() != 1) {
    cout << -1 << endl;
    return 0;
  }
  gone = 1;
  sort(arr + 1, arr + n + 1, comp);
  while (!Q.empty()) {
    cur = Q.front();
    Q.pop();
    for (i = gone + 1; i <= n; i++, gone++) {
      if (arr[i].dist != arr[cur].dist + 1 || arr[cur].adj == k ||
          arr[i].adj == k)
        break;
      ans.push_back(make_pair(arr[cur].indx, arr[i].indx));
      Q.push(i);
      arr[cur].adj++;
      arr[i].adj++;
    }
  }
  if (gone == n) {
    cout << (int)(ans.size()) << endl;
    print_pair(ans, (int)(ans.size()));
  } else
    cout << -1 << endl;
  return 0;
}
