#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> s, t;
vector<pair<int, int> > moves;
bool solve(int depth) {
  if (depth < 0) return false;
  if (equal(s.begin(), s.end(), t.begin())) return true;
  int l = -1;
  for (int i = 0; i < n; i++) {
    if (s[i] != i) {
      l = i;
      break;
    }
  }
  int index = -1;
  for (int i = 0; i < n; i++) {
    if (s[i] == l) {
      index = i;
      break;
    }
  }
  reverse(s.begin() + l, s.begin() + index + 1);
  if (solve(depth - 1)) {
    moves.push_back(make_pair(l, index));
    return true;
  }
  reverse(s.begin() + l, s.begin() + index + 1);
  int r = -1;
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] != i) {
      r = i;
      break;
    }
  }
  if (r == -1) return false;
  index = -1;
  for (int i = 0; i < n; i++) {
    if (s[i] == r) {
      index = i;
      break;
    }
  }
  reverse(s.begin() + index, s.begin() + r + 1);
  if (solve(depth - 1)) {
    moves.push_back(make_pair(index, r));
    return true;
  }
  reverse(s.begin() + index, s.begin() + r + 1);
  return false;
}
int main() {
  int in;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> in;
    s.push_back(in - 1);
    t.push_back(i);
  }
  bool ans = solve(3);
  int size = moves.size();
  cout << size << endl;
  for (int i = 0; i < size; i++)
    cout << (moves[i].first + 1) << " " << (moves[i].second + 1) << endl;
  return 0;
}
