#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, Arr[N], lft[N], rgt[N];
bool ok() {
  for (int i = 1; i <= n; i++) {
    if (Arr[i] != i) return false;
  }
  return true;
}
void dfs(int now) {
  if (ok()) {
    cout << now - 1 << "\n";
    for (int i = now - 1; i >= 1; i--) cout << lft[i] << " " << rgt[i] << "\n";
    exit(0);
  }
  if (now > 3) return;
  for (int i = 1; i <= n; i++) {
    if (Arr[i] != i &&
        (abs(Arr[i] - Arr[i - 1]) > 1 || abs(Arr[i] - Arr[i + 1]) > 1)) {
      for (int j = i + 1; j <= n; j++) {
        if (Arr[j] != j &&
            (abs(Arr[j] - Arr[j - 1]) > 1 || abs(Arr[j] - Arr[j + 1]) > 1)) {
          reverse(Arr + i, Arr + j + 1);
          lft[now] = i, rgt[now] = j;
          dfs(now + 1);
          reverse(Arr + i, Arr + j + 1);
        }
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> Arr[i];
  Arr[n + 1] = -1;
  dfs(1);
  return 0;
}
