#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1100;
int l[MAXN], r[MAXN], a[MAXN];
bool flag;
int n, top;
bool Check() {
  for (int i = 1; i <= n; ++i)
    if (a[i] != i) return false;
  return true;
}
bool DFS(int dep) {
  if (Check()) {
    printf("%d\n", dep);
    for (int i = dep; i >= 1; --i) printf("%d %d\n", l[i], r[i]);
    return true;
  }
  if (dep == 3) 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)) {
          l[dep + 1] = i;
          r[dep + 1] = j;
          reverse(a + i, a + j + 1);
          if (DFS(dep + 1)) return true;
          reverse(a + i, a + j + 1);
        }
  return false;
}
int main() {
  scanf("%d", &n);
  a[0] = a[n + 1] = -1;
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  DFS(0);
  return 0;
}
