#include <bits/stdc++.h>
using namespace std;
int a[1001], n, ans, b[1001];
pair<int, int> p[4];
void rev(int *a, int l, int r) {
  for (int d = 0; l + d < r - d; ++d) swap(a[l + d], a[r - d]);
}
bool search(int x) {
  int l = 1, r = n;
  while (l <= n && a[l] == l) ++l;
  while (r && a[r] == r) --r;
  if (l > r) {
    ans = x - 1;
    return true;
  }
  if (x > 3) return false;
  int t;
  for (t = l; t <= r; t++)
    if (a[t] == l) break;
  rev(a, l, t);
  if (search(x + 1)) {
    p[x] = pair<int, int>(l, t);
    return true;
  }
  rev(a, l, t);
  for (t = l; t <= r; t++)
    if (a[t] == r) break;
  rev(a, t, r);
  if (search(x + 1)) {
    p[x] = pair<int, int>(t, r);
    return true;
  }
  rev(a, t, r);
  return false;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  if (search(1)) {
    printf("%d\n", ans);
    for (int i = ans; i >= 1; i--) printf("%d %d\n", p[i].first, p[i].second);
  } else {
    for (int i = 1; i <= n; i++) b[a[i]] = i;
    for (int i = 1; i <= n; i++) a[i] = b[i];
    search(1);
    printf("%d\n", ans);
    for (int i = 1; i <= ans; i++) printf("%d %d\n", p[i].first, p[i].second);
  }
  return 0;
}
