#include <bits/stdc++.h>
inline int Get() {
  char ch;
  while ((ch = getchar()) < '0' || ch > '9')
    ;
  int Num = ch - '0';
  while ((ch = getchar()) >= '0' && ch <= '9')
    Num = (Num << 3) + (Num << 1) + ch - '0';
  return Num;
}
const int N = 1e3 + 5;
int n, a[N], l[5], r[5];
void dfs(int x) {
  int cnt0 = 0, cnt1 = 0;
  for (int i = 0; i <= n; ++i)
    cnt0 += (a[i + 1] - a[i] != 1), cnt1 += (abs(a[i + 1] - a[i]) != 1);
  if (!cnt0) {
    printf("%d\n", x);
    for (int i = x; i; --i) printf("%d %d\n", l[i], r[i]);
    exit(0);
  }
  if (x + (cnt1 + 1) / 2 > 3) return;
  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)) {
          int delta =
              (abs(a[i - 1] - a[j]) != 1) + (abs(a[j + 1] - a[i]) != 1) - 2;
          if ((x + 1) + (cnt1 + delta + 1) / 2 > 3) continue;
          std ::reverse(a + i, a + j + 1);
          l[x + 1] = i, r[x + 1] = j, dfs(x + 1);
          std ::reverse(a + i, a + j + 1);
        }
    }
}
int main() {
  n = Get(), a[n + 1] = n + 1;
  for (int i = 1; i <= n; ++i) a[i] = Get();
  dfs(0);
}
