#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 + 17;
int n, A[MAXN], L[7], R[7];
void Solve(int u) {
  bool st = true;
  for (int i = 1; i <= n; ++i)
    if (A[i] != i) st = false;
  if (st) {
    cout << u - 1 << "\n";
    for (int i = u - 1; i >= 1; --i) cout << L[i] << " " << R[i] << "\n";
    exit(0);
  }
  if (u > 3) return;
  for (int i = 1; i <= n; ++i)
    if (A[i] != i && (abs(A[i] - A[i - 1]) > 1 || abs(A[i] - A[i + 1]) > 1)) {
      L[u] = i;
      for (int j = i + 1; j <= n; ++j)
        if ((A[j] != j && (abs(A[j] - A[j - 1]) > 1)) ||
            abs(A[j] - A[j + 1]) > 1) {
          reverse(A + i, A + j + 1);
          R[u] = j;
          Solve(u + 1);
          reverse(A + i, A + j + 1);
        }
    }
}
int main() {
  cin >> n;
  A[0] = A[n + 1] = -1;
  for (int i = 1; i <= n; ++i) cin >> A[i];
  Solve(1);
}
