#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <map>
#include <set>
#define MOD 1000000007
#define int long long
#define MAX 1000000000

using namespace std;


void solve()
{
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0;i < n;i++)
		cin >> v[i];

	auto x = v;
	sort(x.begin(), x.end());

	auto head = v.begin();
	auto index = 0;

	vector<pair<int, int>> ans;

	while (x != v)
	{
		auto f = find(v.begin(), v.end(), x[index]);

		ans.push_back({(int)(head - v.begin()), (int)(f - v.begin())});
		f++;
		reverse(head, f);

		head++;
		index++;
	}
	cout << ans.size() << endl;
	for (auto a : ans)
	{
		cout << a.first + 1 << " " << a.second + 1 << endl;
	}
}

signed main()
{
	int t = 1;
	for (int i = 0; i < t; i++)
	{
		solve();
	}
}