#include <bits/stdc++.h>
using namespace std;
int read() {
  static int x;
  static char ch;
  static bool pd;
  pd = true;
  x = 0;
  for (ch = getchar(); ch > '9' || ch < '0'; ch = getchar())
    if (ch == '-') pd = false;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
  return pd ? x : -x;
}
vector<pair<int, int> > ans;
int n, a[100010], L, R, st, ed, cnt;
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) a[i] = read();
  L = 1, R = n, st = 1, ed = a[n] + 1;
  while (L <= R) {
    for (int i = 1; i <= a[L] - a[L - 1]; ++i) {
      for (int j = st + 1; j <= ed; ++j) ans.push_back(make_pair(st, j)), cnt++;
      st++;
    }
    L++;
    ed = a[--R] + 1;
  }
  cout << cnt << endl;
  for (int i = 0; i < cnt; ++i)
    cout << ans[i].first << ' ' << ans[i].second << endl;
  return 0;
}
