#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void program();
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  program();
}
const int MX = 5e5;
int n, a[MX];
pair<int, int> ans[3];
bool sorted() {
  for (int i = int(1); i < int(n + 1); i++)
    if (a[i] != i) return 0;
  return 1;
}
int findAns(int cur) {
  if (sorted()) return cur;
  if (cur == 3) return -1;
  for (int i = int(1); i < int(n + 1); i++) {
    for (int j = int(i + 1); j < int(n + 1); j++) {
      if (abs(a[i] - a[j + 1]) != 1 && abs(a[i - 1] - a[j]) != 1) continue;
      ans[cur] = {i, j};
      reverse(a + i, a + j + 1);
      int ret = findAns(cur + 1);
      if (ret != -1) return ret;
      reverse(a + i, a + j + 1);
    }
  }
  return -1;
}
void program() {
  cin >> n;
  for (int i = int(1); i < int(n + 1); i++) cin >> a[i];
  a[0] = 0;
  a[n + 1] = n + 1;
  int len = findAns(0);
  cout << len << endl;
  for (int i = int(len - 1); i >= int(0); i--)
    cout << ans[i].first << " " << ans[i].second << endl;
}
