#include <bits/stdc++.h>
using namespace std;
const int N = (int)(1e3 + 5);
int n, m, l, r;
int d[N];
bool g[N][N];
void print_degrees() {
  int dg[N];
  memset(dg, 0, sizeof(dg));
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++)
      if (g[i][j]) dg[i]++;
  set<int> s;
  for (int i = 0; i < m; i++) s.insert(dg[i]);
  for (auto x : s) printf("%d ", x);
  putchar('\n');
}
void print_graph() {
  int gm = 0;
  for (int i = 0; i < m; i++)
    for (int j = i + 1; j <= m - 1; j++)
      if (g[i][j]) gm++;
  printf("%d\n", gm);
  for (int i = 0; i < m; i++)
    for (int j = i + 1; j <= m - 1; j++)
      if (g[i][j]) printf("%d %d\n", i + 1, j + 1);
}
void solve(int z) {
  for (int k = 0; k < z; k++) {
    for (int j = l; j <= r - 1; j++) g[j][r] = g[r][j] = true;
    r--;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie();
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &d[i]);
  m = d[n - 1] + 1;
  r = m - 1;
  int i = 0;
  int j = n - 1;
  while (l < r && i <= j) {
    l = r - d[j];
    solve(d[i]);
    for (int k = n - 1; k >= 0; k--) d[k] -= d[i];
    while (d[i] <= 0 && i < n) i++;
    j--;
  }
  print_graph();
  return 0;
}
