#include <bits/stdc++.h>
using namespace std;
int a[100005];
int l[100005];
int r[100005];
int n;
bool check() {
  int i = 1;
  for (i = 1; i <= n; i++) {
    if (a[i] != i) return false;
  }
  return true;
}
void dfs(int num) {
  if (check()) {
    cout << num - 1 << endl;
    for (int i = num - 1; i >= 1; i--) cout << l[i] << " " << r[i] << endl;
    exit(0);
  }
  if (num > 3) {
    return;
  }
  int i, j, j1, k1;
  for (i = 1; i <= n; i++) {
    for (j = i + 1; j <= n; j++) {
      if ((abs(a[i - 1] - a[j]) == 1) || (abs(a[i] - a[j + 1]) == 1)) {
        l[num] = i;
        r[num] = j;
        for (j1 = i, k1 = j; j1 <= k1; j1++, k1--) {
          int tt = a[j1];
          a[j1] = a[k1];
          a[k1] = tt;
        }
        dfs(num + 1);
        for (j1 = i, k1 = j; j1 <= k1; j1++, k1--) {
          int tt = a[j1];
          a[j1] = a[k1];
          a[k1] = tt;
        }
      }
    }
  }
}
int main() {
  int i;
  cin >> n;
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  a[0] = 0;
  a[n + 1] = n + 1;
  dfs(1);
  return 0;
}
