#include <bits/stdc++.h>
using namespace std;
const int maxn = 1002;
int a[maxn], ans[4][2];
int n, m;
int left() {
  for (int i = 1; i <= n; ++i)
    if (a[i] != i) return i;
  return 0;
}
int right() {
  for (int i = n; i; --i)
    if (a[i] != i) return i;
  return 0;
}
int find(int x) {
  for (int i = 1; i <= n; ++i)
    if (a[i] == x) return i;
  return 0;
}
bool dfs(int s) {
  int l, r;
  l = left();
  if (!l) return 1;
  if (s == 3) return 0;
  r = find(l);
  reverse(a + l, a + r + 1);
  if (dfs(s + 1)) {
    ans[m][0] = l;
    ans[m++][1] = r;
    return 1;
  }
  reverse(a + l, a + r + 1);
  r = right();
  l = find(r);
  reverse(a + l, a + r + 1);
  if (dfs(s + 1)) {
    ans[m][0] = l;
    ans[m++][1] = r;
    return 1;
  }
  reverse(a + l, a + r + 1);
  return 0;
}
int main() {
  int i;
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) scanf("%d", &a[i]);
  dfs(0);
  printf("%d\n", m);
  for (i = 0; i < m; ++i) printf("%d %d\n", ans[i][0], ans[i][1]);
  return 0;
}
