#include <bits/stdc++.h>
using namespace std;
int data[1005];
int n;
int m;
struct rever {
  int l, r;
} action[3];
int left() {
  for (int i = 1; i <= n; i++) {
    if (data[i] != i) return i;
  }
  return 0;
}
int right() {
  for (int i = n; i >= 1; i--) {
    if (data[i] != i) return i;
  }
  return 0;
}
int find(int x) {
  for (int i = 1; i <= n; i++) {
    if (data[i] == x) return i;
  }
  return 0;
}
int dfs(int level) {
  int l, r;
  l = left();
  if (l == 0) return 1;
  if (level >= 3) return 0;
  r = find(l);
  reverse(data + l, data + r + 1);
  if (dfs(level + 1)) {
    action[m].l = l;
    action[m++].r = r;
    return 1;
  }
  reverse(data + l, data + r + 1);
  r = right();
  l = find(r);
  reverse(data + l, data + r + 1);
  if (dfs(level + 1)) {
    action[m].l = l;
    action[m++].r = r;
    return 1;
  }
  reverse(data + l, data + r + 1);
  return 0;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> data[i];
  dfs(0);
  cout << m << endl;
  for (int i = 0; i < m; i++) cout << action[i].l << ' ' << action[i].r << endl;
  return 0;
}
