#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) cin >> a[i];
	vector <pair<int, int>> ans;
	for (int i = 0; i < n - 1; i++) {
		for (int j = 0; j < n - i - 1; j++) {
			if (a[j] > a[j + 1]) {
				int x = a[j];
				int y = a[j + 1];
				a[j] = y;
				a[j + 1] = x;
				pair<int, int> cur;
				cur.first = j + 1;
				cur.second = j + 2;
				ans.push_back(cur);
			}
		}
	}
	cout << ans.size() << "\n";
	for (auto i: ans) cout << i.first << " " << i.second << "\n";
}
