#include <bits/stdc++.h>
using namespace std;
int n, i, a[1111], L[11], R[11];
void dfs(int made) {
  bool S = 1;
  for (int i = 1; i <= n; ++i)
    if (a[i] != i) {
      S = 0;
      break;
    }
  if (S) {
    printf("%d\n", made - 1);
    for (int i = made - 1; i > 0; --i) printf("%d %d\n", L[i], R[i]);
    exit(0);
  }
  if (made > 3) return;
  for (int i = 1; i <= n; ++i)
    for (int j = i + 1; j <= n; ++j)
      if ((abs(a[i - 1] - a[j]) == 1) || (abs(a[i] - a[j + 1]) == 1)) {
        L[made] = i, R[made] = j;
        reverse(a + i, a + j + 1);
        dfs(made + 1);
        reverse(a + i, a + j + 1);
      }
}
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) scanf("%d", &a[i]);
  a[0] = 0, a[n + 1] = n + 1;
  dfs(1);
  return 0;
}
