#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
void qread(int &x) {
  int neg = 1;
  x = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') neg = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') x = 10 * x + c - '0', c = getchar();
  x *= neg;
}
const int maxn = 1005;
int n;
int a[maxn], b[maxn];
vector<int> pos;
bool spe[maxn];
inline int check() {
  int c = 0;
  for (int(i) = 1; (i) <= n - 1; i++)
    if (abs(b[i] - b[i + 1]) != 1) c++;
  if (b[n] != n) c++;
  return c;
}
int main() {
  scanf("%d", &n);
  pos.push_back(0);
  pos.push_back(n);
  for (int(i) = 1; (i) <= n; i++) {
    scanf("%d", &a[i]);
    if (i >= 2 && abs(a[i] - a[i - 1]) != 1) {
      pos.push_back(i - 1);
      pos.push_back(a[i]);
      pos.push_back(a[i - 1] - 1);
    }
    b[i] = a[i];
  }
  sort(pos.begin(), pos.end());
  pos.resize(unique(pos.begin(), pos.end()) - pos.begin());
  for (int(i) = 0; (i) < pos.size(); i++) spe[pos[i]] = true;
  if (check() == 0) {
    printf("0");
    return 0;
  }
  for (int(i) = 0; (i) < n + 2; i++)
    if (!spe[i]) {
      pos.insert(lower_bound(pos.begin(), pos.end(), i), i);
      for (int(l1) = 0; (l1) < pos.size(); l1++)
        for (int r1 = l1 + 1; r1 < pos.size(); r1++) {
          if (pos[r1] - pos[l1] == 1) continue;
          for (int(k) = 1; (k) <= (pos[r1] - pos[l1]) / 2; k++)
            swap(b[pos[l1] + k], b[pos[r1] - k + 1]);
          int c = check();
          if (!c) {
            printf("1\n%d %d", pos[l1] + 1, pos[r1]);
            return 0;
          }
          if (c > 4) {
            for (int(k) = 1; (k) <= (pos[r1] - pos[l1]) / 2; k++)
              swap(b[pos[l1] + k], b[pos[r1] - k + 1]);
            continue;
          }
          for (int(l2) = 0; (l2) < pos.size(); l2++)
            for (int r2 = l2 + 1; r2 < pos.size(); r2++) {
              if (pos[r2] - pos[l2] == 1) continue;
              if (l1 == l2 && r1 == r2) continue;
              for (int(k) = 1; (k) <= (pos[r2] - pos[l2]) / 2; k++)
                swap(b[pos[l2] + k], b[pos[r2] - k + 1]);
              int c = check();
              if (!c) {
                printf("2\n%d %d\n%d %d", pos[l2] + 1, pos[r2], pos[l1] + 1,
                       pos[r1]);
                return 0;
              }
              if (c > 2) {
                for (int(k) = 1; (k) <= (pos[r2] - pos[l2]) / 2; k++)
                  swap(b[pos[l2] + k], b[pos[r2] - k + 1]);
                continue;
              }
              int l3 = 0, r3 = 0;
              bool ok = true;
              for (int(k) = 1; (k) <= n - 1; k++)
                if (abs(b[k] - b[k + 1]) != 1) {
                  l3 = k;
                  break;
                }
              if (b[1] != 1) l3 = 0;
              for (int k = n; k >= 2; k--)
                if (abs(b[k] - b[k - 1]) != 1) {
                  r3 = k - 1;
                  break;
                }
              if (b[n] != n) r3 = n;
              for (int k = l3 + 1; k < r3; k++)
                if (b[k] != b[k + 1] + 1) {
                  ok = false;
                  break;
                }
              if (ok) {
                printf("3\n%d %d\n%d %d\n%d %d", l3 + 1, r3, pos[l2] + 1,
                       pos[r2], pos[l1] + 1, pos[r1]);
                return 0;
              }
              for (int(k) = 1; (k) <= (pos[r2] - pos[l2]) / 2; k++)
                swap(b[pos[l2] + k], b[pos[r2] - k + 1]);
            }
          for (int(k) = 1; (k) <= (pos[r1] - pos[l1]) / 2; k++)
            swap(b[pos[l1] + k], b[pos[r1] - k + 1]);
        }
      pos.erase(lower_bound(pos.begin(), pos.end(), i));
    }
  return 0;
}
