#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> construct(vector<int> d) {
  if (d.empty()) return {{}};
  if (d.size() == 1) {
    vector<vector<int>> e(d[0] + 1);
    for (int i = 0; i < e.size(); ++i)
      for (int j = i + 1; j < e.size(); ++j) e[i].push_back(j);
    return e;
  }
  vector<int> d1;
  for (int i = 1; i + 1 < d.size(); ++i) d1.push_back(d[i] - d[0]);
  auto e1 = construct(d1);
  vector<vector<int>> e(d.back() + 1);
  int x = d.back() - d[d.size() - 2];
  for (int i = 0; i < e1.size(); ++i)
    for (int j = 0; j < e1[i].size(); ++j) e[i + x].push_back(e1[i][j] + x);
  for (int i = e.size() - d[0]; i < e.size(); ++i)
    for (int j = 0; j < i; ++j) e[j].push_back(i);
  return e;
}
int main() {
  int n;
  scanf("%d", &n);
  vector<int> d(n);
  for (int i = 0; i < n; ++i) scanf("%d", &d[i]);
  auto e = construct(d);
  int s = 0;
  for (int i = 0; i < e.size(); ++i) s += e[i].size();
  printf("%d\n", s);
  for (int i = 0; i < e.size(); ++i)
    for (int j = 0; j < e[i].size(); ++j) printf("%d %d\n", i + 1, e[i][j] + 1);
  return 0;
}
