#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,tune=native")

#include <iostream>
#include <vector>
#include <set>
#include <cmath>
#include <numeric>
#include <map>
#include <cassert>
#include <algorithm>
#include <random>
#include <stack>

using namespace std;

#define int long long
#define se second
#define fi first

int bins(int l, int r, int val, vector<int>& a)
{
	if (l == r) return l;
	int m = (l + r + 1) >> 1;
	if (a[m] <= val) return bins(m, r, val, a);
	else return bins(l, m - 1, val, a);
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for (auto& i : a) cin >> i;
	vector<pair<int, int>> res;
	for (int i = 1; i < n; ++i)
	{
		if (a[i] < a[0])
		{
			if(1 < i + 1) res.push_back({1, i + 1});
			if(2 < i + 1) res.push_back({ 2, i + 1 });
			for (int j = i; j >= 1; --j) swap(a[j], a[j - 1]);
		}
		else if (a[i] < a[i - 1])
		{
			int pos = bins(0, i - 1, a[i], a);
			if(pos + 2 < i + 1) res.push_back({ pos + 2, i + 1 });
			if(pos + 3 < i + 1) res.push_back({ pos + 3, i + 1 });
			for (int j = i; j >= pos + 2; --j) swap(a[j], a[j - 1]);
		}
	}
	cout << res.size() << '\n';
	int ans = 0;
	for (int i = 0; i < res.size(); ++i) cout << res[i].first << " " << res[i].second << '\n';
	return 0;
}
