#include <bits/stdc++.h>
using namespace std;
vector<int> G[1000 + 5];
int n, totcnt = 0;
int d[300 + 5];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &d[i]);
  int id1 = 0, id2 = d[n] + 2, ans = 0;
  for (int i = 1, j = n; i <= j; i++, j--) {
    int bgid = id1 + 1, edid = id2 - 1;
    for (int k = 1; k <= d[i]; k++) {
      ++id1;
      for (int p = id1 + 1; p <= edid; p++) G[id1].push_back(p), ans++;
    }
    for (int k = 1; k <= d[j] - d[j - 1]; k++) --id2;
    for (int k = i + 1; k <= j - 1; k++) d[k] -= d[i];
  }
  printf("%d\n", ans);
  for (int i = 1; i <= d[n] + 1; i++)
    for (int j = 0; j < (int)G[i].size(); j++) printf("%d %d\n", i, G[i][j]);
  return 0;
}
