#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 pos[1000005];
struct lol
{
	int x, y;
};
lol h[1000005];
vector<lol> v2;
lol h2[1000005];
vector<int> v[1000005];
bool cmp(lol x, lol y)
{
	return x.x < y.x;
}
void solve()
{
	cin >> a;
	for (int i = 1; i <= a; i++)
	{
		cin >> h[i].x;
		h[i].y = i;
		h2[i].x = h[i].x;
		h2[i].y = i;
		pos[h[i].y] = i;
	}
	sort(h2 + 1, h2 + 1 + a, cmp);
	for (int i = 1; i <= a; i++)
	{
		if (h[i].y != h2[i].y)
		{
			int l = i;
			int r = pos[h2[i].y];
			v2.push_back({ l,r });
			while (l <= r)
			{
				swap(h[l], h[r]);
				pos[h[l].y] = l;
				pos[h[r].y] = r;
				l++;
				r--;
			}
			

		}
	}

	cout << v2.size() << '\n';
	for (int i = 0; i < v2.size(); i++)
	{
		cout << v2[i].x << " " << v2[i].y << '\n';
	}

}
/*

3 3 3 3 4 5
*/
signed main() {
	int q = 1;
	//cin >> q;
	while (q != 0)
	{
		solve();
		q--;
	}
}