#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin >> n;

    vector<int> a(n);
    for(int i = 0; i < n; i++)
        cin >> a[i];

    int temp;
    long long int result = 0;
    vector<pair<int, int>> change;

    for(int i = 0; i < n - 1; i++) {
        for(int r = n - 1; r > i; r--) {
            if(a[r] < a[r - 1]) {
                temp = a[r - 1];
                a[r - 1] = a[r];
                a[r] = temp;

                result++;
                change.push_back({r + 1, r + 2});
            }
        }
    }

    cout << result << endl;
    for(pair<int, int> v: change) {
        cout << v.first << " " << v.second << endl;
    }
}
