	#include <algorithm>
	#include <iostream>
	#include <cstdlib>
	#include <cstdarg>
	#include <cassert>
	#include <climits>
	#include <cstring>
	#include <complex>
	#include <cstdio>
	#include <vector>
	#include <string>
	#include <queue>
	#include <cmath>
	#include <ctime>
	#include <set>
	#include <map>
	#include <iomanip>
	#include <unordered_map>
	#include <bitset>
	#include<stack>
	#include <type_traits>
	#include <random>
	#include <chrono>
	#define int long long
	using namespace std;
	long long a, b, c, d, e, f, g;
	long long h[4000005];
	struct lol
	{
		int x, y;
	};
	vector<lol> ans;
	void reverse(int l, int r)
	{
		while (l <= r)
		{
			swap(h[l], h[r]);
			l++;
			r--;
		}

	}
	int doda()
	{
		f = 0;
		for (int i = 1; i <= a; i++)
		{
			f += abs(h[i] - i);
		}
		return f;

	}
	void solve()
	{
		cin >> a;
		for (int i = 1; i <= a; i++)
		{
			cin >> h[i];
		}
		int ll = 1;
		while (doda() != 0)
		{
			int mn = 100000000000000;
			int e = 0, e2 = 0;
			for (int i = 1; i <= a; i++)
			{
				
					reverse(ll, i);
					if (doda() < mn)
					{
						mn = doda();
						e = ll;
						e2 = i;
					}
					reverse(ll, i);
					
				
			}
			reverse(e,e2);
			ans.push_back({ e,e2 });
			ll++;
			if (ll > a)ll = 1;
		}
		cout << ans.size() << '\n';
		for (int i = 0; i < ans.size(); i++)
		{
			cout << ans[i].x << " " << ans[i].y << '\n';
		}
	}
	/*
	6
	3 3 3 3 4 5
	*/
	signed main() {
		int q = 1;
		//cin >> q;
		while (q != 0)
		{
			solve();
			q--;
		}
	}

	/*
	4 4
1 1 3 4 2 2 3 4 1 2 3 3 1 2 4 4
	
	*/