#include <bits/stdc++.h>
using namespace std;
void get_edges(const int i_offset, const int d_offset, const int from_index,
               const int to_index, const vector<int>& D,
               vector<pair<int, int> >& edges) {
  int first_index = i_offset;
  int last_index = first_index + D[to_index] - d_offset;
  for (int i = 0, k = last_index; i < D[from_index] - d_offset; ++i, --k) {
    for (int j = first_index; j < k; ++j) {
      edges.push_back(pair<int, int>(k, j));
    }
  }
  if (to_index - from_index > 1) {
    get_edges(i_offset + D[to_index] - D[to_index - 1], D[from_index],
              from_index + 1, to_index - 1, D, edges);
  }
}
struct Node {
  vector<int> adj;
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N;
  cin >> N;
  vector<int> D(N);
  for (int i = 0; i < N; ++i) {
    cin >> D[i];
  }
  vector<pair<int, int> > res;
  res.reserve(D.back() * (D.back() + 1) / 2);
  get_edges(1, 0, 0, D.size() - 1, D, res);
  cout << res.size() << endl;
  for (int i = 0; i < res.size(); ++i) {
    cout << res[i].first << " " << res[i].second << endl;
  }
  return 0;
}
