#include <bits/stdc++.h>
using namespace std;
const int N = 3e2 + 10;
int n, cnt;
vector<pair<int, int> > ans;
int d[N];
void dfs(int l, int r, int x) {
  if (r < l) {
    cnt++;
    return;
  } else if (r - l == 0) {
    int st = cnt + 1;
    for (int i = st; i <= st + d[l] - x; ++i) {
      for (int j = st; j < i; ++j) {
        ans.push_back(pair<int, int>(j, i));
      }
    }
    cnt += d[l] - x + 1;
    return;
  } else {
    dfs(l + 1, r - 1, d[l]);
    cnt += d[r] - d[r - 1];
    for (int i = 1; i <= cnt; ++i)
      for (int j = cnt + 1; j <= cnt + d[l] - x; ++j) {
        ans.push_back(pair<int, int>(i, j));
      }
    for (int j = cnt + 1; j <= cnt + d[l] - x; ++j) {
      for (int k = cnt + 1; k < j; ++k) ans.push_back(pair<int, int>(k, j));
    }
    cnt += d[l] - x;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &d[i]);
  dfs(1, n, 0);
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); ++i)
    printf("%d %d\n", ans[i].first, ans[i].second);
  return 0;
}
