#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
using namespace std;
const long double eps = 1e-7;
const int inf = 1000000010;
const long long INF = 10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 100010, LOG = 20;
int n, m, k, u, v, x, y, t, a, b, ans;
int A[MAXN], N;
vector<pair<int, int> > out;
void add_edge(int u, int v) { out.push_back({u, v}); }
void build(int tl, int tr) {
  if (tr < tl) {
    N++;
    return;
  }
  if (tl == tr) {
    for (int i = N + 1; i <= N + A[tl] + 1; i++)
      for (int j = i + 1; j <= N + A[tl] + 1; j++) add_edge(i, j);
    N += A[tl] + 1;
    return;
  }
  int cnt = A[tr] - A[tr - 1];
  for (int i = tl + 1; i < tr; i++) A[i] -= A[tl];
  build(tl + 1, tr - 1);
  N += cnt;
  while (A[tl]--) {
    N++;
    for (int i = 1; i < N; i++) add_edge(i, N);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> A[i];
  build(1, n);
  cout << out.size() << '\n';
  for (pair<int, int> p : out) cout << p.first << ' ' << p.second << '\n';
  return 0;
}
