#include <bits/stdc++.h>
using namespace std;
int d[330];
int mp[1010][1010];
int n, dn;
int main() {
  int i, j, k, l, pos = 0;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &d[i]);
  k = 1, dn = d[n];
  for (i = n, j = d[n] + 1; i >= k && d[i]; i--, j = d[i] + 1) {
    while (d[k]) {
      for (l = i; l >= k; l--) d[l]--;
      for (l = 1; l < j; l++) mp[j][l] = mp[l][j] = 1;
      j--;
    }
    while (!d[k] && k <= i) k++;
  }
  for (i = 1; i <= dn + 1; i++)
    for (j = 1; j < i; j++)
      if (mp[i][j] || mp[j][i]) pos++;
  printf("%d\n", pos);
  for (i = 1; i <= dn + 1; i++)
    for (j = 1; j < i; j++)
      if (mp[i][j] || mp[j][i]) printf("%d %d\n", i, j);
  return 0;
}
