// #pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define int long long
#define ft first
#define sc second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define GG cout << " OPA " << '\n';

using namespace std;

const int N = 3e5 + 5;
const int INF = 1e9;

int a[N];
int b[N];

void solve() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i ++) {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b + 1, b + n + 1);
    vector <pair <int, int> > vec;
    for (int j = 1; j <= n; j ++) {
        int pos = 0;
        // cout << b[j] << ' ' << a[j] << '\n';
        for (int i = j; i <= n; i ++) {
            if (a[i] == b[j]) {pos = i; break;}
        }
        assert(pos);
        if (j != pos) vec.pb({j, pos});
        for (int i = j; i < j + (pos - j + 1) / 2; i ++) {
            swap(a[i], a[pos - (i - j)]);
        }
    }
    cout << vec.size() << '\n';
    for (auto it : vec) cout << it.ft << ' ' << it.sc << '\n';
}

main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cerr.tie(0);
    int test = 1;
    // cin >> test;
    while(test --) {
        solve();
    }
}