#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  for (int i = 0; i < n; ++i) {
    cin >> d[i];
  }
  vector<int> s(d[n - 1] + 1);
  for (int i = 0; i < n; ++i) {
    s[d[i]] = 1;
  }
  vector<array<int, 2>> v;
  int l = 0, r = 0;
  while (n > 0 and r < d[n - 1]) {
    do {
      for (int i = l + 2; i <= d[n - 1] + 1; i++) {
        v.push_back({l + 1, i});
      }
      ++l;
    } while (s[++r] == 0);
    --n;
  }
  cout << v.size() << endl;
  for (const auto& x : v) {
    cout << x[0] << ' ' << x[1] << endl;
  }
  return 0;
}
