#include <iostream>
#include <vector>

const int N = 32000;

using namespace std;
typedef long long ll;

int main(){
    int n, a[N];
    cin >> n;
    for(int i = 0; i < n; ++i)
        cin >> a[i];
    vector<pair<int, int>> rs;
    for(int i = 0; i < n; ++i)
        for(int j = 1; j < n - i; ++j)
            if(a[j - 1] > a[j])
                rs.push_back({j, j + 1}),
                swap(a[j - 1], a[j]);
    cout << rs.size() << '\n';
    for(int i = 0; i < n; ++i)
        cout << rs[i].first << ' ' << rs[i].second << '\n';
    return 0;
}

