#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
int n, cc, a[N], L[5], R[5];
bool check() {
  for (int i = 1; i <= n; i++)
    if (a[i] != i) return false;
  return true;
}
bool go(int rem) {
  if (check()) {
    printf("%d\n", cc);
    for (int i = cc; i; i--) printf("%d %d\n", L[i], R[i]);
    return true;
  }
  if (!rem) return false;
  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)) {
          reverse(a + i, a + j + 1);
          cc++;
          L[cc] = i;
          R[cc] = j;
          if (go(rem - 1)) return true;
          cc--;
          reverse(a + i, a + j + 1);
        }
  return false;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  a[0] = a[n + 1] = 100000;
  cc = 0;
  go(3);
  return 0;
}
