#include <bits/stdc++.h>
using namespace std;
int a[100010];
vector<pair<int, int> > v;
int main() {
  int n;
  cin >> n;
  a[0] = 0;
  for (int i = 1; i <= n; i++) cin >> a[i];
  v.resize(0);
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] >= a[i - 1])
      for (int j = 0; j < a[i] - a[i - 1]; j++) v.push_back(make_pair(i, -1));
    else
      for (int j = 0; j < a[i - 1] - a[i]; j++) v[cnt++].second = i - 1;
  }
  while (cnt < (int)v.size()) {
    v[cnt].second = n;
    cnt++;
  }
  cout << cnt << endl;
  for (int i = 0; i < cnt; i++)
    cout << v[i].first << " " << v[i].second << endl;
  return 0;
}
