#include <bits/stdc++.h>
using namespace std;
int n;
int a[1005], g[1005];
int sum, l[5], r[5];
int dfs(int s) {
  int i;
  for (i = 1; i <= n; i++)
    if (a[i] != i) break;
  if (i > n) {
    sum = s - 1;
    return 1;
  }
  if (s > 3) return 0;
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++)
      if (a[i - 1] == a[j] - 1 || a[i] == a[j + 1] - 1) {
        l[s] = i;
        r[s] = j;
        reverse(a + i, a + j + 1);
        if (dfs(s + 1) == 1) return 1;
        reverse(a + i, a + j + 1);
      }
  return 0;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &g[i]), a[g[i]] = i;
  a[0] = 0;
  a[n + 1] = n + 1;
  dfs(1);
  printf("%d\n", sum);
  for (int i = 1; i <= sum; i++) printf("%d %d\n", l[i], r[i]);
  return 0;
}
