#include <bits/stdc++.h>
using namespace std;
int N, A[1111];
int L[3], R[3];
bool judge() {
  for (int n = 1; n <= N; ++n)
    if (A[n] != n) return false;
  return true;
}
void DFS(int K) {
  if (judge()) {
    printf("%d\n", K);
    for (int k = K - 1; ~k; --k) printf("%d %d\n", L[k], R[k]);
    exit(0);
  }
  if (K >= 3) return;
  for (int l = 1; l < N; ++l)
    if (A[l] != l && (abs(A[l] - A[l - 1]) > 1 || abs(A[l] - A[l + 1]) > 1))
      for (int r = l + 1; r <= N; ++r)
        if (A[r] != r &&
            (abs(A[r] - A[r - 1]) > 1 || abs(A[r] - A[r + 1]) > 1)) {
          reverse(A + l, A + r + 1);
          L[K] = l;
          R[K] = r;
          DFS(K + 1);
          reverse(A + l, A + r + 1);
        }
}
int main() {
  scanf("%d", &N);
  for (int n = 1; n <= N; ++n) scanf("%d", A + n);
  A[N + 1] = N + 1;
  DFS(0);
  return 0;
}
