#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
int n, a[N];
vector<pair<int, int> > ans;
int find_left() {
  for (int i = 1; i <= n; ++i)
    if (a[i] != i) return i;
  return 0;
}
int find_right() {
  for (int i = n; i >= 1; --i)
    if (a[i] != i) return i;
  return 0;
}
int find(int x) {
  for (int i = 1; i <= n; ++i)
    if (a[i] == x) return i;
}
bool dfs(int d) {
  int l = find_left(), r = find_right();
  if (!l) return true;
  if (d == 3) return false;
  int l_pos = find(l), r_pos = find(r);
  ans.push_back(make_pair(l, l_pos));
  reverse(a + l, a + l_pos + 1);
  if (dfs(d + 1)) return true;
  reverse(a + l, a + l_pos + 1);
  ans.pop_back();
  ans.push_back(make_pair(r_pos, r));
  reverse(a + r_pos, a + r + 1);
  if (dfs(d + 1)) return true;
  reverse(a + r_pos, a + r + 1);
  ans.pop_back();
  return false;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i);
  dfs(0);
  cout << ans.size() << endl;
  for (int i = (int)ans.size() - 1; i >= 0; --i)
    cout << ans[i].first << ' ' << ans[i].second << endl;
  return 0;
}
