#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1004;
int d[MAXN];
int n, m;
vector<pair<int, int>> v;
void Gouzao(int x, int beg_point) {
  if (x > n) return;
  int nowd = d[x];
  if (x < n) {
    for (int i = beg_point; i < beg_point + nowd; i++) {
      for (int j = i + 1; j < beg_point + nowd; j++) {
        v.push_back(make_pair(i, j));
      }
    }
    for (int i = beg_point; i < beg_point + nowd; i++) {
      for (int j = beg_point + nowd; j <= beg_point + d[n]; j++) {
        v.push_back(make_pair(i, j));
      }
    }
    n--;
    for (int i = x; i <= n; i++) d[i] -= nowd;
    for (int i = x; i <= n; i++)
      if (d[i] > 0) {
        Gouzao(i, beg_point + nowd + 1);
        return;
      }
  } else {
    for (int i = beg_point; i <= beg_point + nowd; i++) {
      for (int j = i + 1; j <= beg_point + nowd; j++) {
        v.push_back(make_pair(i, j));
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    cin >> d[i];
  }
  Gouzao(1, 1);
  cout << v.size() << '\n';
  for (auto i : v) {
    cout << i.first << ' ' << i.second << '\n';
  }
  return 0;
}
