#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:36777216")
using namespace std;
const int inf = 1e9;
const long double eps = 1e-9;
const long double pi = acos(-1.0);
long long xabs(long long x) { return (x < 0 ? -x : x); }
long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }
vector<int> minE(vector<int> &a, int &l, int &r) {
  vector<int> res = a;
  int n = a.size();
  int pos = -1;
  int mi = inf;
  for (int i = 0; i < n; i++) {
    if (a[i] != i + 1 && a[i] < mi) {
      mi = a[i];
      pos = i;
    }
  }
  l = pos;
  r = a[pos] - 1;
  if (l > r) swap(l, r);
  for (int i = l; i <= r; i++) {
    if (i <= r - (i - l)) {
      swap(res[i], res[r - (i - l)]);
    } else
      break;
  }
  return res;
}
vector<int> maxE(vector<int> &a, int &l, int &r) {
  vector<int> res = a;
  int n = a.size();
  int pos = -1;
  int ma = -inf;
  for (int i = 0; i < n; i++) {
    if (a[i] != i + 1 && a[i] > ma) {
      ma = a[i];
      pos = i;
    }
  }
  l = pos;
  r = a[pos] - 1;
  if (l > r) swap(l, r);
  for (int i = l; i <= r; i++) {
    if (i <= r - (i - l)) {
      swap(res[i], res[r - (i - l)]);
    } else
      break;
  }
  return res;
}
bool check(vector<int> &a) {
  int n = a.size();
  for (int i = 0; i < n; i++) {
    if (a[i] != i + 1) return false;
  }
  return true;
}
void go(vector<pair<int, int> > ans, vector<int> mas, int step = 0) {
  if (step > 3) return;
  if (check(mas)) {
    cout << ans.size() << endl;
    for (int i = ans.size() - 1; i >= 0; i--) {
      cout << ans[i].first + 1 << " " << ans[i].second + 1 << endl;
    }
    exit(0);
  } else {
    int l1, r1, l2, r2;
    vector<int> t1, t2;
    t1 = minE(mas, l1, r1);
    ans.push_back(make_pair(l1, r1));
    go(ans, t1, step + 1);
    t2 = maxE(mas, l2, r2);
    ans.pop_back();
    ans.push_back(make_pair(l2, r2));
    go(ans, t2, step + 1);
  }
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<pair<int, int> > z;
  go(z, a);
  return 0;
}
