#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;

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

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

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

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


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