#include <bits/stdc++.h>
using namespace std;
const int maxn = 4000;
int n, d[maxn], p[maxn];
vector<pair<int, int> > re;
bool vis[maxn][maxn];
void build(int l, int r, int f, int s) {
  if (s <= f) return;
  for (int i = s; i >= s - d[l] + 1; i--) {
    for (int j = f; j < s + 1; ++j)
      if (j != i && !vis[i][j]) {
        re.push_back({i, j});
        vis[i][j] = vis[j][i] = 1;
      }
  }
  s -= d[l];
  l++;
  r--;
  for (int i = l; i < r + 1; ++i) {
    d[i] -= d[l - 1];
  }
  int x = d[r] + 1;
  if (l > r) return;
  while (s - f + 1 != x) {
    f++;
    if (s <= f) return;
  }
  build(l, r, f, s);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i < n + 1; ++i) {
    cin >> d[i];
  }
  build(1, n, 1, d[n] + 1);
  cout << re.size() << endl;
  for (auto u : re) cout << u.first << ' ' << u.second << endl;
  return 0;
}
