#include <bits/stdc++.h>

#define INF 1000000005
#define INFL 1000000000000000005ll
#define EPS 1e-6
#define pb push_back
#define pause system("pause")
#define exit exit(0)
#define endl '\n'

using namespace std;
using ull = unsigned long long;
using ll = long long;

typedef pair<ll, ll> pii;
const int N = 32005, MOD = 998244353;

int n, a[N], b[N];
set<int> pos[N];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		b[i] = a[i];
		pos[a[i]].insert(i);
	}

	vector<pii> ans;
	sort(b + 1, b + 1 + n);
	for (int i = 1; i <= n; ++i) {
		if (a[i] != b[i]) {
			int j = *pos[b[i]].upper_bound(i);
			pos[a[i]].erase(i), pos[a[j]].erase(j);
			swap(a[i], a[j]);
			pos[a[i]].insert(i), pos[a[j]].insert(j);
			ans.pb({ i, j });
			if (i + 1 < j - 1) {
				ans.pb({ i + 1, j - 1 });
			}
		}
	}

	cout << ans.size() << endl;
	for (auto x : ans) {
		cout << x.first << ' ' << x.second << endl;
	}
	//pause;
	return 0;
}
