#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, mod = 1e9 + 7;
int n, a[N], l[3], r[3];
bool good() {
  for (int i = 0; i < n; i++) {
    if (a[i] != i) return false;
  }
  return true;
}
void go(int num) {
  if (good()) {
    cout << num << "\n";
    for (int i = num - 1; i >= 0; i--) {
      cout << l[i] + 1 << " " << r[i] + 1 << "\n";
    }
    exit(0);
  }
  if (num == 3) {
    return;
  }
  for (int i = 0; i < n; i++) {
    if (a[i] != i && (i == 0 || abs(a[i] - a[i - 1]) != 1 || i == n - 1 ||
                      abs(a[i + 1] - a[i]) != 1)) {
      for (int j = i + 1; j < n; j++) {
        if (a[j] != j && (j == 0 || abs(a[j] - a[j - 1]) != 1 || j == n - 1 ||
                          abs(a[j + 1] - a[j]) != 1)) {
          reverse(a + i, a + j + 1);
          l[num] = i;
          r[num] = j;
          go(num + 1);
          reverse(a + i, a + j + 1);
        }
      }
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }
  go(0);
  return 0;
}
