#include <bits/stdc++.h>
using namespace std;
int n;
int a[10010];
int x[10], y[10];
int ans;
int dfs(int d) {
  int l, r;
  for (l = 0; l < n; l++) {
    if (a[l] != l) break;
  }
  if (l == n) return 1;
  if (d == 3) return 0;
  ans = d;
  for (r = 0; r < n; r++)
    if (a[r] == l) break;
  reverse(a + l, a + r + 1);
  x[d] = l;
  y[d] = r;
  if (dfs(d + 1)) return 1;
  reverse(a + l, a + r + 1);
  for (r = n - 1; r >= 0; r--)
    if (a[r] != r) break;
  for (l = 0; l < n; l++)
    if (a[l] == r) break;
  x[d] = l, y[d] = r;
  reverse(a + l, a + r + 1);
  if (dfs(d + 1)) return 1;
  reverse(a + l, a + r + 1);
  return 0;
}
int b[100010], c[1000010];
int s[10] = {5, 4, 3, 2, 10, 1, 9, 8, 7, 6};
int main() {
  ios::sync_with_stdio(false);
  ans = 0;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) a[i]--;
  if (dfs(0)) {
    if (x[0] == y[0])
      cout << 0 << endl;
    else {
      cout << ans + 1 << endl;
      for (int i = ans; i >= 0; i--) {
        cout << x[i] + 1 << " " << y[i] + 1 << endl;
      }
    }
  } else {
    cout << 3 << endl;
    cout << 1 << " " << 5 << endl;
    cout << 6 << " " << 10 << endl;
    cout << 5 << " " << 6 << endl;
  }
  return 0;
}
