#include <bits/stdc++.h>
using namespace std;
int n, i;
int A[1024];
vector<pair<int, int> > opers;
void DFS(int Made) {
  bool is_sorted = true;
  for (int i = 1; i < n; i++) {
    if (A[i] > A[i + 1]) {
      is_sorted = false;
      break;
    }
  }
  if (is_sorted) {
    cout << Made << "\n";
    for (int i = Made - 1; i >= 0; i--) {
      cout << opers[i].first << " " << opers[i].second << "\n";
    }
    exit(0);
  } else {
    if (Made == 3) return;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < i - 1; j++) {
      if (abs(A[i] - A[j]) == 1) {
        reverse(A + j + 1, A + i + 1);
        opers.push_back(make_pair(j + 1, i));
        DFS(Made + 1);
        opers.pop_back();
        reverse(A + j + 1, A + i + 1);
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  A[0] = 0;
  for (i = 1; i <= n; i++) cin >> A[i];
  DFS(0);
  assert(false);
  return 0;
}
