#include <bits/stdc++.h>
using namespace std;
int t, b[5], c[5], a[1002], n;
bool judge() {
  for (int i = 1; i <= n; i++)
    if (a[i] != i) return false;
  return true;
}
inline int abs(int x) { return x < 0 ? -x : x; }
inline bool dis(int i) {
  return (abs(a[i] - a[i - 1]) > 1) || (abs(a[i] - a[i + 1]) > 1);
}
int DFS(int d) {
  if (judge()) return t = d;
  if (d > 3) return false;
  for (int i = 1; i <= n; i++)
    if (a[i] != i && dis(i))
      for (int j = i + 1; j <= n; j++)
        if (a[j] != j && dis(j)) {
          reverse(a + i, a + j + 1);
          b[d] = i, c[d] = j;
          if (DFS(d + 1)) return true;
          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[n + 1] = -1;
  DFS(1);
  printf("%d\n", --t);
  for (int i = t; i; i--) printf("%d %d\n", b[i], c[i]);
  printf("\n");
  return 0;
}
