#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char ch = getchar();
  int nega = 1;
  while (!isdigit(ch)) {
    if (ch == '-') nega = -1;
    ch = getchar();
  }
  int ans = 0;
  while (isdigit(ch)) {
    ans = ans * 10 + ch - 48;
    ch = getchar();
  }
  if (nega == -1) return -ans;
  return ans;
}
int add(int x, int y) { return x + y >= 998244353 ? x + y - 998244353 : x + y; }
int sub(int x, int y) { return x - y < 0 ? x - y + 998244353 : x - y; }
int mul(int x, int y) { return 1LL * x * y % 998244353; }
int a[1005], n;
stack<pair<int, int> > ans;
bool ok() {
  for (int i = 1; i <= n; i++) {
    if (i != a[i]) return 0;
  }
  return 1;
}
void dfs(int dep) {
  if (ok()) {
    cout << ans.size() << endl;
    while (!ans.empty()) {
      printf("%d %d\n", ans.top().first, ans.top().second);
      ans.pop();
    }
    exit(0);
  }
  if (dep == 0) return;
  for (int i = 1; i <= n; i++) {
    if (a[i] != i && (abs(a[i] - a[i - 1]) != 1 || abs(a[i] - a[i + 1]) != 1)) {
      for (int j = i + 1; j <= n; j++) {
        if (a[j] != j &&
            (abs(a[j] - a[j - 1]) != 1 || abs(a[j] - a[j + 1]) != 1)) {
          ans.push(make_pair(i, j));
          reverse(a + i, a + j + 1);
          dfs(dep - 1);
          ans.pop();
          reverse(a + i, a + j + 1);
        }
      }
    }
  }
}
signed main() {
  cin >> n;
  for (int i = 1; i <= n; i++) a[i] = read();
  a[0] = -1, a[n + 1] = -1;
  dfs(3);
  return 0;
}
