#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 = 40005, MOD = 998244353;

int n, a[N], b[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];
	}

	vector<pii> ans;
	while (!is_sorted(a + 1, a + 1 + n)) {
		for (int i = 1; i < n; ++i) {
			if (a[i + 1] < a[i]) {
				ans.pb({ i, i + 1 });
				swap(a[i], a[i + 1]);
			}
		}
	}

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