#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cout << *it << " = " << a << endl;
  err(++it, args...);
}
const int MAX = 1005;
int adj[MAX][MAX], d[MAX];
void solve(set<int> &s) {
  if (s.size() == 1) {
    int d1 = *s.begin();
    for (int i = 0; i <= d1; i++) {
      for (int j = i + 1; j <= d1; j++) {
        adj[i][j] = 1;
      }
    }
    return;
  }
  set<int> a;
  int dn = *s.rbegin(), d1 = *s.begin();
  for (int x : s) {
    if (x != dn) {
      a.insert(dn - x);
    }
  }
  solve(a);
  for (int i = 0; i <= dn - d1; i++) {
    for (int j = i + 1; j <= dn - d1; j++) {
      adj[i][j] ^= 1;
    }
  }
  for (int i = 0; i <= dn - d1; i++) {
    for (int j = dn - d1 + 1; j <= dn; j++) {
      adj[i][j] = adj[j][i] = 1;
    }
  }
  for (int i = dn - d1 + 1; i <= dn; i++) {
    for (int j = i + 1; j <= dn; j++) {
      adj[i][j] = adj[j][i] = 1;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  set<int> s;
  for (int i = 0; i < n; i++) {
    cin >> d[i];
    s.insert(d[i]);
  }
  solve(s);
  int dn = d[n - 1];
  vector<pair<int, int>> vp;
  for (int i = 0; i <= dn; i++) {
    for (int j = i + 1; j <= dn; j++) {
      if (adj[i][j]) {
        vp.push_back({i + 1, j + 1});
      }
    }
  }
  cout << vp.size() << "\n";
  for (auto p : vp) {
    cout << p.first << " " << p.second << "\n";
  }
  return 0;
}
