#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ldb = long double;
const long long N = 100500 * 2;
const double eps = 5e-12;
const ldb half = 0.5;
const long long mod = 1020421001;
const long long inf = numeric_limits<long long>::max();
long long d[N];
vector<long long> g[N];
vector<long long> us;
void solve(long long a, long long b, long long was) {
  for (long long i = was; i < (long long)(was + d[a]); ++i) {
    for (long long j = i + 1; j < (long long)(us.size()); ++j) {
      g[i].push_back(j);
      g[j].push_back(i);
    }
  }
  for (long long i = a + 1; i < (long long)(b + 1); ++i) {
    d[i] -= d[a];
  }
  was += d[a];
  d[a] = 0;
  was += d[b] - d[b - 1];
  if (was == us.size() || a >= b) return;
  solve(a + 1, b - 1, was);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  for (long long i = 0; i < n; cin >> d[i], ++i)
    ;
  for (long long i = 0; i < (long long)(d[n - 1] + 1); ++i) {
    us.push_back(i);
  }
  solve(0, n - 1, 0);
  long long cnt = 0;
  for (long long i = 0; i < (long long)(us.size()); ++i) {
    for (auto to : g[i]) {
      assert(i != to);
      if (to > i) ++cnt;
    }
  }
  cout << cnt << '\n';
  for (long long i = 0; i < (long long)(us.size()); ++i) {
    for (auto to : g[i]) {
      if (to > i) {
        cout << i + 1 << " " << to + 1 << '\n';
      }
    }
  }
  return 0;
}
