#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
int n;
vector<int> a;
vector<pair<int, int> > ans;
void solve(int top, vector<int> d) {
  if (d.empty()) return;
  if (d.size() == 1) {
    for (int i = 1; i <= (d[0] + 1); ++i)
      for (int j = i + 1; j <= (d[0] + 1); ++j)
        ans.push_back(make_pair(top + i, top + j));
    return;
  }
  int n = d.size(), c = d[n - 1] - d[n - 2], t = d[0];
  for (int i = 1; i <= (d[0]); ++i)
    for (int j = i + 1; j <= (d[n - 1] + 1); ++j)
      ans.push_back(make_pair(top + i, top + j));
  for (int i = 0; i < (n - 2); ++i) d[i] = d[i + 1] - t;
  d.pop_back(), d.pop_back();
  solve(top + c + t, d);
}
int main(int argc, char *argv[]) {
  scanf("%d", &n);
  a.resize(n);
  for (int i = 0; i < (n); ++i) {
    scanf("%d", &a[i]);
  }
  solve(0, a);
  printf("%d\n", (int)ans.size());
  for (auto i : ans) printf("%d %d\n", i.first, i.second);
  return 0;
}
