#include <bits/stdc++.h>
void swap(int *ll, int *rr, int i, int j) {
  int h, tmp;
  for (h = i; h <= j; h++) tmp = ll[h], ll[h] = rr[h], rr[h] = tmp;
  while (i < j) {
    tmp = ll[i], ll[i] = ll[j], ll[j] = tmp;
    tmp = rr[i], rr[i] = rr[j], rr[j] = tmp;
    i++, j--;
  }
}
int check(int *ll, int *rr, int cnt) {
  int i;
  for (i = 0; i < cnt; i++)
    if (ll[i] > rr[i]) return 0;
  for (i = 1; i < cnt; i++)
    if (rr[i - 1] + 1 != ll[i]) return 0;
  return 1;
}
int main() {
  static int aa[1000], ll[15], rr[15], pp[3], qq[3], uu[3], vv[3];
  int n, i, cnt;
  scanf("%d", &n);
  cnt = 0;
  for (i = 0; i < n; i++) scanf("%d", &aa[i]), aa[i]--;
  for (i = 0; i < n; i++) {
    if (i == 0 || abs(aa[i - 1] - aa[i]) > 1) ll[cnt] = aa[i];
    if (i + 1 == n || abs(aa[i + 1] - aa[i]) > 1) {
      int l = ll[cnt];
      int r = aa[i];
      if (abs(r - l) + 1 == 2) {
        ll[cnt] = l, rr[cnt++] = l;
        ll[cnt] = r, rr[cnt++] = r;
      } else
        ll[cnt] = l, rr[cnt++] = r;
    }
  }
  ll[cnt] = rr[cnt] = n, cnt++;
  for (pp[0] = 0; pp[0] < cnt; pp[0]++)
    for (qq[0] = pp[0]; qq[0] < cnt; qq[0]++) {
      if (qq[0] == cnt - 1 && pp[0] != cnt - 1) continue;
      for (pp[1] = 0; pp[1] < cnt; pp[1]++)
        for (qq[1] = pp[1]; qq[1] < cnt; qq[1]++) {
          if (qq[1] == cnt - 1 && pp[1] != cnt - 1) continue;
          for (pp[2] = 0; pp[2] < cnt; pp[2]++)
            for (qq[2] = pp[2]; qq[2] < cnt; qq[2]++) {
              int yes, op, h;
              if (qq[2] == cnt - 1 && pp[2] != cnt - 1) continue;
              for (h = 0; h < 3; h++) swap(ll, rr, pp[h], qq[h]);
              yes = check(ll, rr, cnt);
              for (h = 2; h >= 0; h--) swap(ll, rr, pp[h], qq[h]);
              if (!yes) continue;
              op = 0;
              for (h = 0; h < 3; h++)
                if (ll[pp[h]] != rr[qq[h]]) {
                  int k;
                  k = 0;
                  for (i = 0; i < pp[h]; i++) k += abs(rr[i] - ll[i]) + 1;
                  uu[op] = k + 1;
                  k = 0;
                  for (i = cnt - 1; i > qq[h]; i--) k += abs(rr[i] - ll[i]) + 1;
                  vv[op++] = n + 1 - k;
                  swap(ll, rr, pp[h], qq[h]);
                }
              printf("%d\n", op);
              while (op--) printf("%d %d\n", uu[op], vv[op]);
              return 0;
            }
        }
    }
  return 0;
}
