#include <bits/stdc++.h>
using namespace std;
const long long int N = 1e5 + 10;
long long int n, d[N], x, k, dg[N], m = 0, BH = 0, y = 0, r;
void degset(long long int l, long long int r, long long int s, long long int f,
            long long int t) {
  if (f - s == 0) {
    for (; l <= r; l++) {
      dg[l] = d[s];
      y += d[s];
    }
    return;
  }
  if (f - s == 1) {
    for (int i = 1; i <= d[s] - t; i++, l++) {
      dg[l] = d[f];
      y += d[f];
    }
    for (int i = 1; i <= d[f] - d[f - 1] + 1; i++, r--) {
      dg[r] = d[s];
      y += d[s];
    }
    return;
  }
  for (int i = 1; i <= d[s] - t; i++, l++) {
    dg[l] = d[f];
    y += d[f];
  }
  for (int i = 1; i <= d[f] - d[f - 1]; i++, r--) {
    dg[r] = d[s];
    y += d[s];
  }
  t += d[s] - t;
  degset(l, r, s + 1, f - 1, t);
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> d[i];
  }
  degset(1, d[n] + 1, 1, n, 0);
  y /= 2;
  cout << y << endl;
  for (int i = 1; i <= d[n] + 1; i++) {
    x = i;
    for (int j = 1; j <= dg[i]; j++) {
      x++;
      dg[x]--;
      cout << i << ' ' << x << '\n';
    }
  }
}
