#include <bits/stdc++.h>
using namespace std;
int n, m, la, cnt, tot, a[1001];
vector<int> aa, bb;
void build(int op, int x) {
  int i;
  if (!op) return;
  cnt++;
  for (i = x + 1; i <= tot; i++) {
    aa.push_back(x);
    bb.push_back(i);
  }
}
int main() {
  int i, l, r;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  tot = a[n] + 1;
  for (i = 1, l = 1, r = n; i <= tot && l <= r; i++) {
    if (cnt + tot - i == a[r]) {
      r--;
      build(1, i);
      la = 1;
    } else if (cnt == a[l]) {
      l++;
      la = 0;
    } else
      build(la, i);
  }
  for (; i <= tot; i++) build(la, i);
  printf("%d\n", aa.size());
  for (i = 0; i < aa.size(); i++) printf("%d %d\n", aa[i], bb[i]);
}
