#include <bits/stdc++.h>
using namespace std;
vector<int> block;
bool flag = false;
int arr[1001];
int n;
void print(int o, int p) {
  int sum = 0;
  for (int i = 0; i < o; i++) {
    sum += (abs(block[i * 2] - block[i * 2 + 1]) + 1);
  }
  cout << sum + 1 << " ";
  for (int i = o; i <= p; i++) {
    sum += (abs(block[i * 2] - block[i * 2 + 1]) + 1);
  }
  cout << sum << endl;
}
void deverse(int o, int p) {
  int tt;
  for (int i = 0; i < (p - o + 1) / 2; i++) {
    tt = block[o + i];
    block[o + i] = block[p - i];
    block[p - i] = tt;
  }
}
bool istrue() {
  if (arr[block[0]] != 1) return false;
  int size = block.size();
  if (arr[block[size - 1]] != n) return false;
  if (size == 2) return true;
  for (int i = 1; i < size - 1; i += 2) {
    if (arr[block[i + 1]] - arr[block[i]] != 1) return false;
  }
  return true;
}
void dfs(int num) {
  int blonum = block.size() / 2;
  for (int i = 0; i < blonum; i++) {
    for (int j = i; j < blonum; j++) {
      if (i == j && block[i * 2] == block[i * 2 + 1]) continue;
      deverse(i * 2, j * 2 + 1);
      if (istrue()) flag = true;
      if (flag == true) {
        cout << num << endl;
        print(i, j);
        deverse(i * 2, j * 2 + 1);
        return;
      }
      if (num < 3) {
        dfs(num + 1);
      }
      if (flag == true) {
        print(i, j);
        deverse(i * 2, j * 2 + 1);
        return;
      }
      deverse(i * 2, j * 2 + 1);
    }
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  int flag = 0;
  int begin = 0;
  for (int i = 1; i <= n; i++) {
    if (begin == 0) {
      begin = i;
    } else {
      if (flag == 0) {
        if (arr[i] - arr[i - 1] == 1) {
          flag = 1;
        } else if (arr[i] - arr[i - 1] == -1) {
          flag = -1;
        } else {
          block.push_back(begin);
          block.push_back(begin);
          begin = i;
          flag = 0;
        }
      } else {
        if (arr[i - 1] + flag != arr[i]) {
          if (i - 1 - begin == 1) {
            block.push_back(begin);
            block.push_back(begin);
            block.push_back(i - 1);
            block.push_back(i - 1);
            begin = i;
            flag = 0;
          } else {
            block.push_back(begin);
            block.push_back(i - 1);
            begin = i;
            flag = 0;
          }
        }
      }
    }
  }
  block.push_back(begin);
  block.push_back(n);
  if (istrue()) {
    cout << 0 << endl;
    return 0;
  }
  dfs(1);
  return 0;
}
