#include <bits/stdc++.h>
using namespace std;
int as[40], bs[40], ss[40];
int ass[40], bss[40], sss[40];
int np;
int f(int p);
int sta[5], stb[5], ans;
int main(void) {
  int n, i;
  int a1, a2;
  int z;
  int npp;
  np = 0;
  scanf("%d", &n);
  a1 = -100;
  z = 0;
  for (i = 1; i <= n; i++) {
    scanf("%d", &a2);
    if (z == 1) {
      if (a2 != a1 + 1) {
        z = 0;
        bs[np] = a1;
        as[++np] = a2;
        ss[np] = 1;
      } else {
        ss[np]++;
      }
    } else if (z == 2) {
      if (a2 != a1 - 1) {
        z = 0;
        bs[np] = a1;
        as[++np] = a2;
        ss[np] = 1;
      } else {
        ss[np]++;
      }
    } else {
      if (a2 == a1 + 1) {
        z = 1;
        ss[np]++;
      } else if (a2 == a1 - 1) {
        z = 2;
        ss[np]++;
      } else {
        z = 0;
        bs[np] = a1;
        as[++np] = a2;
        ss[np] = 1;
      }
    }
    a1 = a2;
  }
  bs[np] = a1;
  npp = 0;
  for (i = 1; i <= np; i++) {
    if (as[i] != bs[i]) {
      if (bs[i] > as[i]) {
        ass[++npp] = as[i];
        bss[npp] = as[i];
        sss[npp] = 1;
        ass[++npp] = as[i] + 1;
        bss[npp] = bs[i];
        sss[npp] = ss[i] - 1;
      } else {
        ass[++npp] = as[i];
        bss[npp] = as[i];
        sss[npp] = 1;
        ass[++npp] = as[i] - 1;
        bss[npp] = bs[i];
        sss[npp] = ss[i] - 1;
      }
    } else {
      ass[++npp] = as[i];
      bss[npp] = as[i];
      sss[npp] = 1;
    }
  }
  np = npp;
  for (i = 1; i <= np; i++) {
    as[i] = ass[i];
    bs[i] = bss[i];
    ss[i] = sss[i];
  }
  f(0);
  n = 0;
  for (i = 1; i <= ans; i++) {
    if (sta[i] != stb[i]) {
      sta[++n] = sta[i];
      stb[n] = stb[i];
    }
  }
  ans = n;
  printf("%d\n", ans);
  for (i = ans; i; i--) {
    printf("%d %d\n", sta[i], stb[i]);
  }
  return 0;
}
int f(int p) {
  int z;
  int sum, sum2;
  int i, j, j2, j3;
  int temp;
  z = 0;
  if (as[1] <= bs[1]) {
    z = 1;
    for (i = 2; i <= np; i++) {
      if (as[i] < bs[i - 1]) {
        z = 0;
        break;
      }
      if (as[i] > bs[i]) {
        z = 0;
        break;
      }
    }
  }
  if (z) {
    ans = p;
    return 1;
  } else {
    if (p == 3) {
      return 0;
    } else {
      z = 0;
      sum = 0;
      for (i = 1; i <= np; i++) {
        sum2 = sum;
        for (j = i; j <= np; j++) {
          sum2 += ss[j];
          for (j2 = i; j2 <= j; j2++) {
            temp = as[j2];
            as[j2] = bs[j2];
            bs[j2] = temp;
          }
          for (j2 = i, j3 = j; j2 < j3; j2++, j3--) {
            temp = as[j2];
            as[j2] = as[j3];
            as[j3] = temp;
            temp = bs[j2];
            bs[j2] = bs[j3];
            bs[j3] = temp;
            temp = ss[j2];
            ss[j2] = ss[j3];
            ss[j3] = temp;
          }
          sta[p + 1] = sum + 1;
          stb[p + 1] = sum2;
          z = f(p + 1);
          if (z) {
            break;
          }
          for (j2 = i; j2 <= j; j2++) {
            temp = as[j2];
            as[j2] = bs[j2];
            bs[j2] = temp;
          }
          for (j2 = i, j3 = j; j2 < j3; j2++, j3--) {
            temp = as[j2];
            as[j2] = as[j3];
            as[j3] = temp;
            temp = bs[j2];
            bs[j2] = bs[j3];
            bs[j3] = temp;
            temp = ss[j2];
            ss[j2] = ss[j3];
            ss[j3] = temp;
          }
        }
        if (z) {
          break;
        }
        sum += ss[i];
      }
      return z;
    }
  }
}
