#include <bits/stdc++.h>
const double eps = (1e-9);
using namespace std;
int dcmp(long double a, long double b) {
  return fabsl(a - b) <= eps ? 0 : (a > b) ? 1 : -1;
}
int getBit(long long num, int idx) { return ((num >> idx) & 1ll) == 1; }
int setBit1(int num, int idx) { return num | (1 << idx); }
long long setBit0(long long num, int idx) { return num & ~(1ll << idx); }
long long flipBit(long long num, int idx) { return num ^ (1ll << idx); }
void M() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int countNumBit1(int mask) {
  int ret = 0;
  while (mask) {
    mask &= (mask - 1);
    ++ret;
  }
  return ret;
}
int n;
vector<int> v;
vector<pair<int, int> > ans;
int degree[10009], ok[10009];
map<pair<int, int>, int> mb;
int main() {
  cin >> n;
  int no;
  for (int i = 0; i < n; i++) {
    cin >> no;
    v.push_back(no);
  }
  int N = v.back() + 1;
  int index = n - 1;
  int id = N, en = N + 1;
  while (index >= 0) {
    vector<pair<int, int> > v1;
    for (int i = 1; i <= N; i++) {
      if (ok[i] || i == id) continue;
      auto it = lower_bound(((v).begin()), ((v).end()), degree[i]);
      int diff = (*it) - degree[i];
      v1.push_back(make_pair(diff, i));
    }
    sort(((v1).rbegin()), ((v1).rend()));
    int till = v[index];
    for (int i = 0; i < ((int)(v1).size()) && degree[id] < till; i++) {
      int val = v1[i].second;
      mb[make_pair(id, val)] = 1;
      mb[make_pair(val, id)] = 1;
      ans.push_back(make_pair(id, val));
      degree[id]++;
      degree[val]++;
    }
    int fl = 0;
    if (degree[id] == till) {
      ok[id] = 1;
      fl = 1;
    } else if (degree[id] > till) {
      for (int i = id - 1; i >= 1; i--) {
        if (degree[i] == till) {
          ok[i] = 1;
          fl = 1;
          break;
        }
        if (degree[i] < till) {
          id = i;
          break;
        }
      }
    }
    if (fl == 1) {
      id--;
      index--;
    }
  }
  while (1) {
    vector<pair<int, int> > v1;
    for (int i = 1; i <= N; i++) {
      if (ok[i]) {
        continue;
      }
      auto it = lower_bound(((v).begin()), ((v).end()), degree[i]);
      int diff = (*it) - degree[i];
      v1.push_back(make_pair(diff, i));
    }
    if (((int)(v1).size()) == 0) break;
    sort(((v1).rbegin()), ((v1).rend()));
    int org = v1[0].second;
    int till = v1[0].first;
    if (till == 0) break;
    for (int i = 1; i < ((int)(v1).size()) && till; i++) {
      int no1 = v1[i].second;
      if (mb[make_pair(org, no1)] == 1) continue;
      mb[make_pair(org, no1)] = 1;
      mb[make_pair(no1, org)] = 1;
      ans.push_back(make_pair(org, no1));
      till--;
      degree[org]++;
      degree[no1]++;
    }
  }
  cout << ((int)(ans).size()) << endl;
  for (int i = 0; i < ((int)(ans).size()); i++)
    cout << ans[i].first << " " << ans[i].second << endl;
}
