#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <set>
#include <map>
using namespace std;
const int maxn=;
struct point
{
int x, y;
};
int n;
int sum;
int a[maxn], des[maxn];
point ans[];
void init()
{
scanf("%d", &n);
a[]=; a[n+]=n+;
for (int i=; i<=n; ++i) scanf("%d", &a[i]);
}
void rev(int le, int ri)
{
for (int i=le; i<=(ri+le)/; ++i)
swap(a[i], a[ri-(i-le)]);
}
bool check()
{
for (int i=; i<=n; ++i)
if (a[i]!=i) return false;
return true;
}
void print(int step)
{
printf("%d\n", step);
for (int i=step; i>; --i)
printf("%d %d\n", ans[i].x, ans[i].y);
exit();
}
void dfs(int k)
{
if (check()) print(k-);
if (k>) return;
for (int i=; i<n; ++i)
for (int j=i+; j<=n; ++j)
if (abs(a[i-]-a[j])== || abs(a[i]-a[j+])==)
{
ans[k].x=i;
ans[k].y=j;
rev(i, j);
dfs(k+);
rev(i, j);
}
}
int main()
{
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
init();
dfs();
return ;
}