#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
string tostr(int n) {
  stringstream rr;
  rr << n;
  return rr.str();
}
const int mod = 1e9 + 7;
const int mxn = 1e5 + 9;
const long double eps = 1e-9;
vector<pair<long long, long long> > ans;
long long deg[mxn];
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  long long i, j, k, n, m, st;
  cin >> m;
  for (i = 1; i <= m; i++) cin >> deg[i];
  n = deg[m] + 1;
  st = 1;
  while (n) {
    for (i = 1; i < n; i++) ans.push_back({i, n});
    for (i = st; i <= m; i++) deg[i]--;
    if (deg[st] == 0) {
      m--;
      if (st > m)
        n = 0;
      else
        n = deg[m] + 1;
      st++;
    } else
      n--;
  }
  cout << ans.size() << "\n";
  for (auto x : ans) cout << x.first << ' ' << x.second << "\n";
  return 0;
}
