#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = ((res % p) * (x % p)) % p;
    y = y >> 1;
    x = ((x % p) * (x % p)) % p;
  }
  return res;
}
long long raichu(long long x, long long y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = ((res) * (x));
    y = y >> 1;
    x = ((x) * (x));
  }
  return res;
}
bool isprime(long long n) {
  if (n < 2)
    return false;
  else if (n == 2)
    return true;
  else if (n % 2 == 0)
    return false;
  else {
    long long z = sqrt(n);
    for (int i = 0; i < z - 1; i++)
      if (n % (i + 2) == 0) return false;
    return true;
  }
}
vector<int> num(1005, 0);
void solve(int times, vector<int> &a, vector<pair<int, int> > &ans,
           vector<int> &tmp) {
  if (tmp == a) {
    cout << (int)ans.size() << endl;
    for (int i = 0; i < (int)ans.size(); i++)
      cout << ans[(int)ans.size() - 1 - i].first << " "
           << ans[(int)ans.size() - 1 - i].second << endl;
    exit(0);
  } else if (times == 3)
    return;
  else {
    vector<int> idxs;
    int n = (int)a.size();
    for (int i = 0; i < (int)a.size(); i++) {
      if (i == 0) {
        if (a[i] != 1) {
          idxs.push_back(i);
        }
      } else if (i == n - 1) {
        if (a[i] != n) {
          idxs.push_back(i);
        }
      } else {
        int z = a[i];
        if (z == 1 || z == n) {
          idxs.push_back(i);
        } else {
          if ((a[i - 1] == z - 1 && a[i + 1] == z + 1) ||
              (a[i - 1] == z + 1 && a[i + 1] == z - 1))
            continue;
          else {
            idxs.push_back(i);
          }
        }
      }
    }
    sort(idxs.begin(), idxs.end());
    vector<int> temp;
    temp.push_back(idxs[0]);
    for (int i = 1; i < (int)idxs.size(); i++) {
      if (idxs[i] != idxs[i - 1]) temp.push_back(idxs[i]);
    }
    idxs = temp;
    vector<pair<int, int> > invs;
    for (int i = 0; i < (int)idxs.size(); i++) {
      for (int j = i + 1; j < (int)idxs.size(); j++) {
        invs.push_back(make_pair(idxs[i], idxs[j]));
      }
    }
    for (int i = 0; i < (int)invs.size(); i++) {
      reverse(a.begin() + invs[i].first, a.begin() + invs[i].second + 1);
      ans.push_back(make_pair(invs[i].first + 1, invs[i].second + 1));
      solve(times + 1, a, ans, tmp);
      ans.pop_back();
      reverse(a.begin() + invs[i].first, a.begin() + invs[i].second + 1);
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int tests = 1, Tests;
  Tests = tests;
  while (tests--) {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<pair<int, int> > ans;
    vector<int> tmp(n);
    for (int i = 0; i < n; i++) tmp[i] = i + 1;
    for (int i = 0; i < (int)a.size(); i++) {
      if (i == 0) {
        if (a[i] != 1) {
          num[(a[i] - 1)] = 1;
          ;
        }
      } else if (i == n - 1) {
        if (a[i] != n) {
          num[(a[i] - 1)] = 1;
          ;
        }
      } else {
        int z = a[i];
        if (z == 1 || z == n) {
          num[(a[i] - 1)] = 1;
          ;
        } else {
          if ((a[i - 1] == z - 1 && a[i + 1] == z + 1) ||
              (a[i - 1] == z + 1 && a[i + 1] == z - 1))
            continue;
          else {
            num[(a[i] - 1)] = 1;
            ;
          }
        }
      }
    }
    solve(0, a, ans, tmp);
  }
  return 0;
}
