#include <bits/stdc++.h>

#define ll long long
#define us unsigned short
#define ui unsigned int

using namespace std;

int main() {
    us n, x, buff;
    cin >> n;
    vector<int> a;
    vector<pair<int, int> > swaps;
    for (int i=0; i < n; i++) {
        cin >> x;
        a.push_back(x);
    }

    for (int j=0; j < n; j++) {
        for (int i=0; i < n-1; i++) {
            if (a[i] > a[i+1]) {
                swap(a[i], a[i+1]);
                swaps.push_back({i+1, i+2});
            }
        }
    }

    cout << swaps.size() << '\n';
    for (const pair<int, int> p : swaps) {
        cout << p.first << " " << p.second << '\n';
    }

    return 0;
}