#include <iostream>
#include <vector>

using namespace std;

vector<int> a;

bool isGrowing(int n) {
    for(int i = 1; i < n; i++) {
        if(a[i-1] > a[i])
            return false;
    }
    return true;
}

int main() {
    int n;
    cin >> n;
    vector<int> c;

    for(int i = 0; i < n; i++) {
        int num;
        cin >> num;
        a.push_back(num);
    }

    while(!isGrowing(n)) {
        for(int i = 1; i < n; i++) {
            if (a[i-1] < a[i]) {
                int min = 32001, el;
                for (int j = i + 1; j < n; j++) {
                    if (min > a[j]) {
                        min = a[j];
                        el = j;
                    }
                }
                if (min < a[i]) {
                    swap(a[i], a[el]);
                    c.push_back(i);
                    c.push_back(el);
                    break;
                }
            }
            else if(a[i-1] > a[i]) {
                swap(a[i - 1], a[i]);
                c.push_back(i-1);
                c.push_back(i);
                break;
            }
        }
    }
    cout << c.size() / 2;

    for(int i = 0; i < c.size(); i+=2)
        cout << '\n' << c[i]+1 << ' ' << c[i+1]+1;
}