#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;
int n, t[N], h[N], s[N];
vector<int> src, snk, ans;
bool dfs(int d) {
  if (src == snk) return 1;
  if (d == 3) return 0;
  vector<int> v;
  for (int i = 0; i < n; i++)
    if (s[src[i]]) v.push_back(i);
  for (int i = 0; i < v.size(); i++)
    for (int j = i + 1; j < v.size(); j++) {
      reverse(src.begin() + v[i], src.begin() + v[j] + 1);
      if (dfs(d + 1)) {
        ans.push_back(v[i] * 1001 + v[j]);
        return 1;
      }
      reverse(src.begin() + v[i], src.begin() + v[j] + 1);
    }
  return 0;
}
int main() {
  for (; ~scanf("%d", &n);) {
    for (int i = 0; i < n; i++) {
      scanf("%d", t + i);
      h[--t[i]] = i;
    }
    s[0] = s[n - 1] = 1;
    for (int i = 0; i < n - 1; i++)
      if (abs(h[i] - h[i + 1]) > 1) s[i] = s[i + 1] = 1;
    src.resize(n);
    for (int i = 0; i < n; i++) src[i] = i;
    snk.assign(t, t + n);
    ans.clear();
    dfs(0);
    printf("%d\n", (int)ans.size());
    for (int i = ans.size() - 1; i >= 0; i--)
      printf("%d %d\n", ans[i] / 1001 + 1, ans[i] % 1001 + 1);
  }
  return 0;
}
