#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double eps = 1e-8;
const double PI = acos(-1.0);
const int MAXN = 1e5 + 5;
const int MAXM = 2e6 + 5;
const int MOD = 1e9 + 7;
int sgn(double x) {
  if (fabs(x) < eps) return 0;
  if (x < 0)
    return -1;
  else
    return 1;
}
long long pw(long long a, long long n, long long mod) {
  long long ret = 1;
  while (n) {
    if (n & 1) ret = ret * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return ret;
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
void inc(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
void dec(long long &a, long long b) {
  a -= b;
  if (a < 0) a += MOD;
}
int mul(int a, int b) {
  long long c = 1ll * a * b;
  return c - c / MOD * MOD;
}
int n, m, d[305], du[1005];
vector<pair<int, int> > e;
bool cmp(int a, int b) { return a > b; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n + 1; i++) scanf("%d", &d[i]);
  m = d[n] + 1;
  sort(d + 1, d + 1 + n, cmp);
  int i = 1, j = m, l = 1, r = n;
  while (1) {
    if (i > j) break;
    if (du[i] + j - i == d[l]) {
      du[i] += j - i;
      for (int k = i + 1; k < j + 1; k++) e.push_back(make_pair(i, k)), du[k]++;
      i++;
      l++;
    } else if (l > 1 && du[i] + j - i == d[l - 1]) {
      du[i] += j - i;
      for (int k = i + 1; k < j + 1; k++) e.push_back(make_pair(i, k)), du[k]++;
      i++;
    }
    if (du[j] == d[r]) {
      j--;
      r--;
    } else if (r < n && du[j] == d[r + 1]) {
      j--;
    }
  }
  printf("%d\n", ((int)(e).size()));
  for (auto p : e) printf("%d %d\n", p.first, p.second);
}
