#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0;
  int f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int MAXN = 10005;
int a[MAXN], lp[MAXN], rp[MAXN];
int n, top, flag;
inline bool check() {
  for (int i = 1; i <= n; i++)
    if (a[i] != i) return 0;
  return 1;
}
inline void rever(int l, int r) {
  if (l > r) swap(l, r);
  lp[top] = l;
  rp[top] = r;
  for (int i = 0; i < (r - l + 1) / 2; i++) swap(a[l + i], a[r - i]);
}
void dfs(int k) {
  if (flag) return;
  if (check()) {
    flag = 1;
    printf("%d\n", top);
    for (int i = top; i; i--) printf("%d %d\n", lp[i], rp[i]);
    return;
  }
  if (k == 0) 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)) {
          top++;
          rever(i, j);
          dfs(k - 1);
          rever(lp[top], rp[top]);
          top--;
        }
}
int main(int argc, char const *argv[]) {
  n = read();
  for (int i = 1; i <= n; ++i) a[i] = read();
  a[0] = a[n + 1] = -1;
  dfs(3);
  return 0;
}
