#include <bits/stdc++.h>
using namespace std;
int a[1011];
vector<pair<int, int> > ans;
int n;
bool check() {
  for (int i = 0; i < n; i++)
    if (a[i] != i + 1) return 0;
  return 1;
}
bool rec(int it) {
  if (check()) return 1;
  if (it == 0) return 0;
  vector<int> pos;
  pos.push_back(0);
  for (int i = 1; i < n - 1; i++) {
    if (!(abs(a[i] - a[i + 1]) == 1 and abs(a[i] - a[i - 1]) == 1)) {
      pos.push_back(i);
    }
  }
  pos.push_back(n - 1);
  for (int i = 0; i < pos.size(); i++) {
    for (int j = i + 1; j < pos.size(); j++) {
      reverse(a + pos[i], a + pos[j] + 1);
      if (rec(it - 1)) {
        ans.push_back({pos[i], pos[j]});
        reverse(a + pos[i], a + pos[j] + 1);
        return 1;
      }
      reverse(a + pos[i], a + pos[j] + 1);
    }
  }
  return 0;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  rec(3);
  cout << ans.size() << "\n";
  for (auto x : ans) {
    cout << x.first + 1 << " " << x.second + 1 << "\n";
  }
}
