#include <bits/stdc++.h>
using namespace std;
const int nsz = 1e3;
int n, d[nsz + 5];
set<pair<int, int> > est;
vector<pair<int, int> > ans;
void inline link(int u, int v) {
  if (est.find(make_pair(u, v)) != est.end()) return;
  est.insert(make_pair(u, v)), est.insert(make_pair(v, u));
  ans.push_back(make_pair(u, v));
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &d[i]);
  for (int l = 1, r = n, del = 0; l <= r; del = d[l], ++l, --r) {
    for (int u = del + 1; u <= d[l]; ++u)
      for (int v = del + 1; v <= d[r] + 1; ++v)
        if (u != v) link(u, v);
  }
  printf("%d\n", int(ans.size()));
  for (int i = 0; i < ans.size(); ++i)
    printf("%d %d\n", ans[i].first, ans[i].second);
}
