#include <bits/stdc++.h>

using namespace std;

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

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; i++)cin >> a[i];
    for (int i = n - 1; i >= 0; i--) {
        for (int j = 0; j < i; j++) {
            if (a[j] > a[j + 1]) {
                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';
    return 0;
}
/**
5
2 4 3 5 1
*/
