#include <bits/stdc++.h>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto& i : a) cin >> i;
    vector<pair<int, int>> ops;
    for (int i = 0; i < n; ++i) {
        auto it = min_element(a.begin() + i, a.end());
        if (a[i] == *it) continue;
        int ind = it - a.begin();
        for (int j = ind; j > i; ++j) {
            ops.push_back({j - 1, j});
            swap(a[j - 1], a[j]);
        }

    }
    cout << ops.size() << '\n';
    for (auto [l, r] : ops) {
        cout << l + 1 << ' ' << r + 1 << '\n';
    }
    return 0;
}