#include <bits/stdc++.h>
using namespace std;
int n, a[1005], pos[1005];
bool check() {
  for (int i = 1; i <= n; i++)
    if (a[i] != i) return 0;
  return 1;
}
int L[6], R[6], top = 0;
bool flag = 0;
void rever(int l, int r) {
  if (l > r) swap(l, r);
  L[top] = l;
  R[top] = r;
  for (int i = 0; i < (r - l + 1) / 2; i++) swap(a[l + i], a[r - i]);
}
void Dfs(int k) {
  if (flag) return;
  if (check()) {
    flag = 1;
    printf("%d\n", top);
    for (int i = top; i; i--) printf("%d %d\n", L[i], R[i]);
    return;
  }
  if (k == 0) 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))
      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)) {
          top++;
          rever(i, j);
          Dfs(k - 1);
          rever(L[top], R[top]);
          top--;
        }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  a[0] = a[n + 1] = -1;
  Dfs(3);
  return 0;
}
