#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    long long int n;
    cin >> n;

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

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

    for(long long int i = 1; i < n; ++i) {
        for(long long 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;
    }
}
