#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const int MAXN = 1010;
int a[MAXN];
int n;
vector<int> vals;
vector<pair<int, int> > ans;
int pos[3][MAXN];
void output() {
  printf("%d\n", ((int)(ans).size()));
  for (int i = int(((int)(ans).size())) - 1; i >= 0; i--)
    printf("%d %d\n", ans[i].first, ans[i].second);
  exit(0);
}
bool good() {
  for (int i = 0; i < int(n - 1); i++)
    if (a[i] > a[i + 1]) return false;
  return true;
}
void go(int done) {
  if (good()) output();
  if (done == 3) {
    return;
  }
  for (int i = 0; i < int(n); i++) pos[done][a[i]] = i;
  for (int i = 0; i < int(((int)(vals).size())); i++)
    for (int j = int(i + 1); j < int(((int)(vals).size())); j++) {
      int l = pos[done][vals[i]];
      int r = pos[done][vals[j]];
      if (l > r) swap(l, r);
      ans.push_back(make_pair(l + 1, r + 1));
      reverse(a + l, a + r + 1);
      go(done + 1);
      ans.pop_back();
      reverse(a + l, a + r + 1);
    }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < int(n); i++) scanf("%d", &a[i]);
  vals.push_back(a[0]);
  vals.push_back(a[n - 1]);
  for (int i = int(1); i < int(n - 1); i++)
    if (abs(a[i - 1] - a[i]) != 1 || abs(a[i + 1] - a[i]) != 1)
      vals.push_back(a[i]);
  go(0);
  return 0;
}
