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

int main() {
	int n;
	cin >> n;
    vector <int> a(n);
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);
    vector <pair <int, int> >  ans;
    bool f = 1;
    while (f) {
        f = 0;
        for (int i = 0; i < n - 1; i++)
            if (a[i] > a[i + 1]) {
                swap(a[i], a[i + 1]);
                ans.push_back({i + 1, i + 2});
                f = 1;
                break;
            }
    }
    cout << ans.size() << endl; 
    for (auto i : ans)
        printf("%d %d\n", i.first, i.second);
    return 0;
}
