#include <bits/stdc++.h>
using namespace std;
template <typename T>
using V = vector<T>;
bool ok[1020];
bool done = false;
V<pair<int, int> > ans;
bool trial(V<pair<int, int> > op, vector<int> b) {
  if (is_sorted((b).begin(), (b).end())) {
    ans = op;
    done = true;
    return true;
  }
  if (op.size() == 3) {
    return false;
  }
  for (int i = 0; i < b.size(); i++) {
    for (int j = i + 1; j < b.size(); j++) {
      if (ok[b[i]] && ok[b[j]]) {
        reverse(b.begin() + i, b.begin() + j + 1);
        op.push_back({b[i], b[j]});
        if (trial(op, b)) {
          return true;
        }
        op.pop_back();
        reverse(b.begin() + i, b.begin() + j + 1);
      }
    }
  }
  return false;
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int &u : a) {
    cin >> u;
    u--;
  }
  vector<int> b;
  set<int> crit;
  for (int i = 0; i < n;) {
    int left = i, right = i;
    for (int j = i; j + 1 < n; j++) {
      if (a[j + 1] - a[j] == a[i + 1] - a[i] && abs(a[i + 1] - a[i]) == 1) {
        right++;
      } else {
        break;
      }
    }
    for (int d = -1; d <= 1; d++) {
      crit.insert(left + d), crit.insert(right + d);
    }
    ok[a[left]] = ok[a[right]] = true;
    i = right + 1;
  }
  for (int u : crit) {
    if (u >= 0 && u < n) {
      b.push_back(a[u]);
    }
  }
  vector<pair<int, int> > op;
  assert(trial(op, b));
  reverse((ans).begin(), (ans).end());
  vector<int> P(n);
  for (int i = 0; i < n; i++) {
    P[i] = i;
  }
  cout << ans.size() << endl;
  for (auto u : ans) {
    int L = find((P).begin(), (P).end(), u.first) - P.begin(),
        R = find((P).begin(), (P).end(), u.second) - P.begin();
    reverse(P.begin() + L, P.begin() + R + 1);
    cout << L + 1 << ' ' << R + 1 << endl;
  }
  return 0;
}
