#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 10;
const int mod = 1e9 + 7;
int n, a[maxn];
int k, ansl[5], ansr[5];
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + c - '0';
    c = getchar();
  }
  return x * f;
}
inline void solve(int st) {
  int flag = 1;
  for (int i = 1; i <= n && flag; i++) flag &= (i == a[i]);
  if (flag) {
    printf("%d\n", st - 1);
    for (int i = st - 1; i >= 1; i--) printf("%d %d\n", ansl[i], ansr[i]);
    exit(0);
  }
  if (st <= 3) {
    int m = 0, w[1000];
    for (int i = 1; i <= n; i++)
      if (abs(a[i] - a[i - 1]) > 1 || abs(a[i] - a[i + 1]) > 1) w[++m] = i;
    for (int i = 1; i < m; i++)
      for (int j = i + 1; j <= m; j++) {
        reverse(a + w[i], a + w[j] + 1);
        ansl[st] = w[i], ansr[st] = w[j];
        solve(st + 1);
        reverse(a + w[i], a + w[j] + 1);
      }
  }
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  a[0] = 0, a[n + 1] = n + 1;
  solve(1);
  return 0;
}
