#include <bits/stdc++.h>
using namespace std;
int n, du[23333], ans, m, mt, s;
int u[2333333], v[2333333], num[23333];
inline int read() {
  int sum = 0;
  char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) sum = sum * 10 + (ch ^ 48), ch = getchar();
  return sum;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    du[i] = read();
    mt = max(mt, du[i]);
    num[du[i]] = 1;
  }
  int l = 0, r = 0;
  while (l < du[n]) {
    while (1) {
      l++;
      for (int i = l + 1; i <= du[n] + 1; i++) {
        u[++s] = l, v[s] = i;
      }
      r++;
      if (num[r]) break;
    }
    n--;
  }
  printf("%d\n", s);
  for (int i = 1; i <= s; i++) printf("%d %d\n", u[i], v[i]);
  return 0;
}
