#include <bits/stdc++.h>

using namespace std;

int n;
vector<int> a;
vector<pair<int, int> > ans;

int main()
{
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; i++)cin >> a[i];
    for (int i = 0; i < n; i++) {
        for (int j = n - 2; j >= 0; j--) {
            if (a[j + 1] < a[j]) {
                ans.push_back({j, j + 1});
                swap(a[j], a[j + 1]);
            }
        }
    }
    cout << ans.size() << '\n';
    for (auto [i, j] : ans)
        cout << i + 1 << " " << j + 1 << '\n';
}
/**
5
2 4 3 5 1
*/
