#include <bits/stdc++.h>
using namespace std;
const int M = 300005;
int n;
int a[M] = {0};
vector<pair<int, int> > edges;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int i = 0;
  int j = n - 1;
  int currentP = 0;
  while (i <= j) {
    if (i == j) {
      for (int k = currentP + 1; k < currentP + a[i] + 1; k++) {
        for (int d = k + 1; d <= a[n - 1] + 1; d++) {
          edges.push_back(make_pair(k, d));
        }
      }
    } else {
      for (int k = currentP + 1; k < currentP + a[i] + 1; k++) {
        for (int d = k + 1; d <= a[n - 1] + 1; d++) {
          edges.push_back(make_pair(k, d));
        }
      }
      currentP += a[i] + a[j] - a[j - 1];
      for (int k = i + 1; k <= j - 1; k++) {
        a[k] -= a[i];
      }
    }
    i++;
    j--;
  }
  printf("%d\n", edges.size());
  for (int k = 0; k < edges.size(); k++) {
    printf("%d %d\n", edges[k].first, edges[k].second);
  }
  return 0;
}
