#include <bits/stdc++.h>
using namespace std;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  std::fill((T *)array, (T *)(array + N), val);
}
vector<int> make_vector(vector<int> d, int n) {
  vector<int> a, b(n), c(n);
  int s = d[0] + 1;
  while (1) {
    for (int i = 0; i < (int)(n); ++i) {
      b[i] = rand() % 10000;
    }
    int ss = 0;
    for (int i = 0; i < (int)(n); ++i) {
      ss += b[i];
    }
    int cc = 0;
    for (int i = 0; i < (int)(n - 1); ++i) {
      c[i] = 1 + ((s - n) * b[i]) / ss;
      cc += c[i];
    }
    c[n - 1] = s - cc;
    random_shuffle(c.begin(), c.end());
    vector<int> p;
    for (int i = 0; i < (int)(n); ++i) {
      for (int j = 0; j < (int)(c[i]); ++j) {
        p.push_back(d[i]);
      }
    }
    vector<int> q(s);
    q[0] = p[0];
    for (int i = 0; i < (int)(s - 1); ++i) {
      q[i + 1] = q[i] + p[i + 1];
    }
    if (q[s - 1] % 2 != 0) continue;
    bool flag = 1;
    for (int i = 0; i < (int)(n); ++i) {
      int xxx = 0;
      for (int j = i + 1; j < s; j++) {
        xxx += min(p[j], i + 1);
      }
      if (q[i] > i * (i + 1) + xxx) {
        flag = 0;
        break;
      }
    }
    if (flag) {
      a = p;
      break;
    }
  }
  return a;
}
int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < (int)(n); ++i) cin >> p[i];
  reverse(p.begin(), p.end());
  vector<int> c = make_vector(p, n);
  vector<pair<int, int> > q(c.size());
  for (int i = 0; i < (int)(c.size()); ++i) {
    q[i] = make_pair(c[i], i);
  }
  n = q.size();
  vector<pair<int, int> > m;
  while (1) {
    sort(q.begin(), q.end(), greater<pair<int, int> >());
    if (q[0].first == 0) break;
    int y = q[0].first;
    q[0].first = 0;
    for (int i = 1; i <= y; i++) {
      q[i].first -= 1;
      m.push_back(make_pair(q[0].second, q[i].second));
    }
  }
  printf("%d\n", (int)m.size());
  for (int i = 0; i < (int)(m.size()); ++i) {
    printf("%d %d\n", m[i].first + 1, m[i].second + 1);
  }
  return 0;
}
