#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];
	int ac[n];
	for (int i = 0; i < n; i++) {int x; cin >> x; a[i] = x; ac[i] = x;}
	long long cnt = 0;
	for (int i = 0; i < n - 1; i++) {
		for (int j = 0; j < n - i - 1; j++) {
			if (ac[j] > ac[j + 1]) {
				int x = ac[j];
				int y = ac[j + 1];
				ac[j] = y;
				ac[j + 1] = x;
				//cout << j + 1 << " " << j + 2 << "\n";
				cnt++;
			}
		}
	}
	cout << cnt << "\n";
	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;
				cout << j + 1 << " " << j + 2 << "\n";
			}
		}
	}
}
