#include <bits/stdc++.h>
using namespace std;
int v[1010];
int x[5], y[5];
bool dfs(int l, int r, int flag) {
  while (l <= r && v[l] == l) ++l;
  while (l <= r && v[r] == r) --r;
  if (l > r) {
    printf("%d\n", flag);
    for (int i = flag - 1; i >= 0; --i) printf("%d %d\n", x[i], y[i]);
    return 1;
  }
  if (flag >= 3) return 0;
  for (int i = l; i <= r; ++i) {
    if (v[i] == l) {
      x[flag] = l;
      y[flag] = i;
      reverse(v + l, v + i + 1);
      if (dfs(l, r, flag + 1)) return 1;
      reverse(v + l, v + i + 1);
    } else if (v[i] == r) {
      x[flag] = i;
      y[flag] = r;
      reverse(v + i, v + r + 1);
      if (dfs(l, r, flag + 1)) return 1;
      reverse(v + i, v + r + 1);
    }
  }
  return 0;
}
int main() {
  int n;
  while (cin >> n) {
    for (int i = (1); i <= (n); ++i) scanf("%d", &v[i]);
    dfs(1, n, 0);
  }
  return 0;
}
