#include <bits/stdc++.h>
using namespace std;
int ans[7], flag;
int a[1005], n;
int pos[4][30], pn[4];
struct Pair {
  int l, r;
} p[4][300];
int pai[4];
stack<int> s;
bool check() {
  for (int i = 1; i <= n; i++) {
    if (a[i] != i) return false;
  }
  return true;
}
void find_pos(int index) {
  pn[index] = 0;
  pos[index][++pn[index]] = 1;
  for (int i = 2; i < n; i++) {
    if (!((a[i - 1] == a[i] + 1 && a[i + 1] == a[i] - 1) ||
          (a[i - 1] == a[i] - 1 && a[i + 1] == a[i] + 1)))
      pos[index][++pn[index]] = i;
  }
  pos[index][++pn[index]] = n;
}
void to_pair(int index) {
  pai[index] = 0;
  for (int i = 1; i <= pn[index]; i++) {
    for (int j = i; j <= pn[index]; j++) {
      p[index][++pai[index]].l = pos[index][i];
      p[index][pai[index]].r = pos[index][j];
    }
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  find_pos(1);
  to_pair(1);
  for (int i = 1; i <= pai[1]; i++) {
    reverse(a + p[1][i].l, a + p[1][i].r + 1);
    find_pos(2);
    if (pn[2] > 10) {
      reverse(a + p[1][i].l, a + p[1][i].r + 1);
      continue;
    }
    s.push(p[1][i].r);
    s.push(p[1][i].l);
    to_pair(2);
    for (int j = 1; j <= pai[2]; j++) {
      reverse(a + p[2][j].l, a + p[2][j].r + 1);
      find_pos(3);
      if (pn[3] > 6) {
        reverse(a + p[2][j].l, a + p[2][j].r + 1);
        continue;
      }
      s.push(p[2][j].r);
      s.push(p[2][j].l);
      to_pair(3);
      for (int k = 1; k <= pai[3]; k++) {
        reverse(a + p[3][k].l, a + p[3][k].r + 1);
        flag = 0;
        if (check()) {
          flag = 1;
          s.push(p[3][k].r);
          s.push(p[3][k].l);
          ans[0] = s.size() / 2;
          ans[1] = s.top();
          s.pop();
          ans[2] = s.top();
          s.pop();
          ans[3] = s.top();
          s.pop();
          ans[4] = s.top();
          s.pop();
          ans[5] = s.top();
          s.pop();
          ans[6] = s.top();
          s.pop();
          for (int i = 1; i <= 5; i += 2) {
            if (ans[i] == ans[i + 1]) {
              ans[0]--;
            }
          }
          cout << ans[0] << endl;
          for (int i = 1; i <= 5; i += 2) {
            if (ans[i] != ans[i + 1])
              cout << ans[i] << " " << ans[i + 1] << endl;
          }
        }
        if (flag) break;
        reverse(a + p[3][k].l, a + p[3][k].r + 1);
      }
      if (flag) break;
      reverse(a + p[2][j].l, a + p[2][j].r + 1);
      s.pop();
      s.pop();
    }
    if (flag) break;
    reverse(a + p[1][i].l, a + p[1][i].r + 1);
    s.pop();
    s.pop();
  }
}
