#include <bits/stdc++.h>
const int M = 1024;
int save[M];
int main(void) {
  int n, ans = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &save[i]);
  int vecs = save[n] + 1;
  int r = n, l = 1, ready = 0;
  for (int vec = 1; vec < vecs; ++vec) {
    if (save[l] <= ready)
      ++l, --r;
    else if (ready + vecs - vec == save[r])
      ++ready, ans += vecs - vec;
  }
  printf("%d\n", ans);
  r = n, l = 1, ready = 0;
  for (int vec = 1; vec < vecs; ++vec) {
    if (save[l] <= ready)
      ++l, --r;
    else if (ready + vecs - vec == save[r]) {
      for (int j = vec + 1; j <= vecs; ++j) printf("%d %d\n", vec, j);
      ++ready;
      ans += vecs - vec;
    }
  }
  return 0;
}
