#include <bits/stdc++.h>
using namespace std;
using LL = long long;
template <class T>
int size(T &&x) {
  return int(x.size());
}
template <class A, class B>
ostream &operator<<(ostream &out, const pair<A, B> &p) {
  return out << '(' << p.first << ", " << p.second << ')';
}
template <class T>
auto operator<<(ostream &out, T &&x) -> decltype(x.begin(), out) {
  out << '{';
  for (auto it = x.begin(); it != x.end(); ++it)
    out << *it << (it == prev(x.end()) ? "" : ", ");
  return out << '}';
}
void dump() {}
template <class T, class... Args>
void dump(T &&x, Args... args) {
  cerr << x << ";  ";
  dump(args...);
}
mt19937_64 rng(0);
int rd(int l, int r) { return uniform_int_distribution<int>(l, r)(rng); }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int _degsize;
  cin >> _degsize;
  vector<int> d(_degsize);
  for (int &di : d) cin >> di;
  vector<pair<int, int>> edges;
  auto add_edge = [&](int v, int u) {
    assert(v != u);
    edges.emplace_back(v, u);
  };
  while (size(d)) {
    0 && cerr;
    int n = d.back() + 1;
    if (size(d) == 1) {
      for (int v = (0); v <= ((n)-1); ++v)
        for (int u = (0); u <= ((v)-1); ++u) add_edge(v, u);
      d.clear();
      break;
    }
    int max_cnt = d.front();
    for (int &di : d) di -= max_cnt;
    for (int v = (n - max_cnt); v <= (n - 1); ++v)
      for (int u = (0); u <= ((v)-1); ++u) add_edge(v, u);
    d.erase(d.begin());
    d.erase(prev(d.end()));
  }
  cout << size(edges) << '\n';
  for (auto [v, u] : edges) cout << v + 1 << ' ' << u + 1 << '\n';
}
