#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 _ = 0; _ < n; ++_) {
        for (int i = 0; i < n - 1; ++i) {
            if (a[i] > a[i + 1]) {
                ops.push_back({i, i + 1});
                swap(a[i], a[i + 1]);
            }
        }
    }
    cout << ops.size() << '\n';
    for (auto [l, r] : ops) {
        cout << l + 1 << ' ' << r + 1 << '\n';
    }
    return 0;
}