#include <bits/stdc++.h>
using namespace std;
int i, j, k, n, m, mas[3000], s, p, rez[10000], z, r;
vector<int> ab[10000];
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin >> m;
  i = 0;
  while (i < m) {
    cin >> mas[i];
    i++;
  }
  n = mas[m - 1] + 1;
  if (m % 2 == 1) {
    if (m == 1) {
      cout << n * (n - 1) / 2 << "\n";
      i = 0;
      while (i < n) {
        j = i + 1;
        while (j < n) {
          cout << i + 1 << " " << j + 1 << "\n";
          j++;
        }
        i++;
      }
      return 0;
    } else {
      i = 0;
      while (i <= mas[(m) / 2] - mas[(m - 2) / 2]) {
        j = i + 1;
        while (j <= mas[(m) / 2] - mas[(m - 2) / 2]) {
          ab[i].push_back(j);
          r++;
          j++;
        }
        i++;
      }
    }
    s = mas[(m) / 2] - mas[(m - 2) / 2] + 1;
    j = 3;
    while (j <= m) {
      s += mas[(m + j - 1) / 2] - mas[(m + j - 1) / 2 - 1];
      k = 0;
      if ((m - j + 1) / 2 == 0) {
        z = 0;
      } else {
        z = mas[(m - j + 1) / 2 - 1];
      }
      while (k < mas[(m - j + 1) / 2] - z) {
        p = 0;
        while (p < s) {
          ab[p].push_back(s);
          r++;
          p++;
        }
        s++;
        k++;
      }
      j += 2;
    }
    cout << r << "\n";
    i = 0;
    while (i < n) {
      for (int j : ab[i]) {
        rez[i]++;
        rez[j]++;
        cout << i + 1 << " " << j + 1 << "\n";
      }
      i++;
    }
  } else {
    s = 1;
    j = 0;
    while (j < m) {
      s += mas[(m + j) / 2] - mas[(m + j) / 2 - 1];
      k = 0;
      if ((m - j - 1) / 2 == 0) {
        z = 0;
      } else {
        z = mas[(m - j - 1) / 2 - 1];
      }
      while (k < mas[(m - j - 1) / 2] - z) {
        p = 0;
        while (p < s) {
          ab[p].push_back(s);
          r++;
          p++;
        }
        s++;
        k++;
      }
      j += 2;
    }
    cout << r << "\n";
    i = 0;
    while (i < n) {
      for (int j : ab[i]) {
        rez[i]++;
        rez[j]++;
        cout << i + 1 << " " << j + 1 << "\n";
      }
      i++;
    }
  }
  i = 0;
  while (i < n) {
    i++;
  }
  return 0;
}
