#include <bits/stdc++.h>
using namespace std;
int n, arr[1005] = {}, orig[1005];
bool bad[1005] = {};
vector<int> loc, l, r, resl, resr;
bool is_sorted() {
  for (int i = 0; i + 1 < loc.size(); i++)
    if (loc[i] > loc[i + 1]) return 0;
  return 1;
}
bool arr_is_sorted() {
  for (int i = 0; i < n; i++)
    if (arr[i + 1] < arr[i]) return 0;
  return 1;
}
void dfs(int depth) {
  if (depth > 3) return;
  if (is_sorted()) {
    for (int i = 0; i < depth; i++) {
      int a = find(arr, arr + n, l[i]) - arr,
          b = find(arr, arr + n, r[i]) - arr;
      if (a > b) swap(a, b);
      for (int j = a; j <= (a + b) / 2; j++) swap(arr[j], arr[b - (j - a)]);
      resl.push_back(a);
      resr.push_back(b);
    }
    if (arr_is_sorted()) {
      cout << depth << '\n';
      while (resl.size()) {
        cout << resl.back() << " " << resr.back() << '\n';
        resl.pop_back();
        resr.pop_back();
      }
      exit(0);
    } else {
      resl.clear();
      resr.clear();
      for (int i = 0; i <= n; i++) arr[i] = orig[i];
    }
  }
  for (int i = 0; i < loc.size(); i++) {
    for (int j = i + 1; j < loc.size(); j++) {
      for (int k = i; k <= (i + j) / 2; k++) swap(loc[k], loc[j - (k - i)]);
      l.push_back(loc[i]);
      r.push_back(loc[j]);
      dfs(depth + 1);
      l.pop_back();
      r.pop_back();
      for (int k = i; k <= (i + j) / 2; k++) swap(loc[k], loc[j - (k - i)]);
    }
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> arr[i];
  n++;
  arr[n] = n;
  for (int i = 0; i <= n; i++) orig[i] = arr[i];
  for (int i = 0; i < n; i++) {
    if (abs(arr[i + 1] - arr[i]) != 1) {
      bad[i] = 1;
      bad[i + 1] = 1;
    }
  }
  for (int i = 1; i < n; i++)
    if (bad[i]) loc.push_back(arr[i]);
  dfs(0);
}
