#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 7 + 2000;
int dig[MAX_N], n;
bool sear(int step) {
  bool pass = true;
  for (int i = 1; i <= n; i++)
    if (dig[i] != i) pass = false;
  if (pass) {
    printf("%d\n", step - 1);
    return true;
  }
  if (step > 3) return false;
  for (int l = 1; l <= n; l++)
    for (int r = l + 1; r <= n; r++)
      if (abs(dig[r] - dig[l - 1]) == 1) {
        reverse(dig + l, dig + r + 1);
        if (sear(step + 1)) {
          printf("%d %d\n", l, r);
          return true;
        }
        reverse(dig + l, dig + r + 1);
      }
  return false;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &dig[i]);
  if (!sear(1)) puts("233");
}
