#include <bits/stdc++.h>
using namespace std;
int d[1005], c[1005], f[1000005][2];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> d[i];
  d[0] = 0;
  for (int i = 1; i <= d[n] + 1; i++) c[i] = 0;
  int m = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = d[i - 1] + 1; j <= d[i]; j++) {
      if (c[j] == d[n - i + 1]) continue;
      for (int k = j + 1; c[j] < d[n - i + 1]; k++) {
        c[j]++;
        c[k]++;
        f[m][0] = j;
        f[m][1] = k;
        m++;
      }
    }
  }
  cout << m << endl;
  for (int i = 0; i < m; i++) cout << f[i][0] << " " << f[i][1] << endl;
  return 0;
}
