#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > b[5];
bool getVector(vector<int> &a, int n, bool d, int &LL, int &RR) {
  int l, r;
  if (d) {
    l = 1;
    while (a[l] == l) ++l;
    if (l == n + 1) return true;
    for (int i = 1; i <= n; i++)
      if (a[i] == l) r = i;
  } else {
    r = n;
    while (a[r] == r) --r;
    if (r == 0) return true;
    for (int i = 1; i <= n; i++)
      if (a[i] == r) l = i;
  }
  LL = l, RR = r;
  int k = (r - l + 1) / 2;
  for (int i = l, j = r; i < l + k; i++, j--) swap(a[i], a[j]);
  return false;
}
int main() {
  int n;
  cin >> n;
  vector<int> a;
  a.push_back(-1);
  for (int i = 1, x; i <= n; i++) cin >> x, a.push_back(x);
  a.push_back(10000);
  b[0].push_back(a);
  int count = 0;
  int cnt = 1;
  int L[6][20], R[6][20];
  bool done = false;
  for (int i = 1; i <= 4; i++) {
    cnt = 1;
    for (int j = 0; j < b[i - 1].size(); j++) {
      vector<int> temp = b[i - 1][j];
      done = getVector(temp, n, 1, L[i][cnt], R[i][cnt]);
      b[i].push_back(temp);
      ++cnt;
      if (done) break;
      temp = b[i - 1][j];
      done = getVector(temp, n, 0, L[i][cnt], R[i][cnt]);
      b[i].push_back(temp);
      ++cnt;
      if (done) break;
    }
    if (done) break;
    ++count;
  }
  cnt /= 2;
  if (count < 4) {
    cout << count << endl;
    while (count--)
      cout << L[count + 1][cnt] << " " << R[count + 1][cnt] << endl,
          cnt = (cnt + 1) / 2;
  } else {
    cout << 3 << endl;
    cout << 1 << " " << 5 << endl;
    cout << 6 << " " << 10 << endl;
    cout << 5 << " " << 6 << endl;
  }
}
