#include <bits/stdc++.h>
using namespace std;
int n, m, sum, fl;
int s[305], e[1005], t[1000005][2];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &s[i]);
  m = s[n] + 1;
  int l = 1, r = n;
  for (int i = 1; i <= m; i++) {
    if (e[i] + m - i == s[r]) {
      for (int j = i + 1; j <= m; j++)
        sum++, t[sum][0] = i, t[sum][1] = j, e[j]++;
      fl = 1;
      r--;
    } else if (e[i] == s[l]) {
      fl = 0;
      l++;
    } else if (fl == 1) {
      for (int j = i + 1; j <= m; j++)
        sum++, t[sum][0] = i, t[sum][1] = j, e[j]++;
    }
  }
  printf("%d\n", sum);
  for (int i = 1; i <= sum; i++) printf("%d %d\n", t[i][0], t[i][1]);
  return 0;
}
