#include <bits/stdc++.h>
using namespace std;
const int mod = 20123;
const int maxn = 211001;
const int INF = 0x7f7f7f7f;
int n, a[maxn], sz;
bool flag = false;
pair<int, int> st[maxn];
int left() {
  for (int i = 1; i <= n; ++i) {
    if (a[i] ^ i) return i;
  }
  return -1;
}
int right() {
  for (int i = n; i >= 1; --i) {
    if (a[i] ^ i) return i;
  }
  return -1;
}
int find(int x) {
  for (int i = 1; i <= n; ++i) {
    if (a[i] == x) return i;
  }
  return -1;
}
bool dfs(int dep) {
  if (flag) return true;
  int l = left(), r = right();
  if (l < 0) {
    sz = dep;
    return true;
  }
  if (dep >= 3) return false;
  int lr = find(l);
  st[dep] = pair<int, int>(l, lr);
  reverse(a + l, a + lr + 1);
  if (dfs(dep + 1)) return true;
  reverse(a + l, a + lr + 1);
  lr = find(r);
  st[dep] = pair<int, int>(lr, r);
  reverse(a + lr, a + r + 1);
  if (dfs(dep + 1)) return true;
  reverse(a + lr, a + r + 1);
  return false;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i);
  dfs(0);
  printf("%d\n", sz);
  for (int i = sz - 1; i >= 0; --i) {
    printf("%d %d\n", st[i].first, st[i].second);
  }
  return 0;
}
