#include <bits/stdc++.h>

#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define watch(x) cout << (#x) << " : " << x << '\n'
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

void solve() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    pair<int, int> ans[n];
    int cur = 0;
    for (int i = 0; i < n; i++) {
        int mx_id = 0;
        for (int j = 0; j < n - i; j++)
            if (a[mx_id] < a[j])
                mx_id = j;
        if (mx_id + 1 != n - i) {
            ans[cur++] = {mx_id + 1, n - i};
            reverse(a + mx_id, a + n - i);
        }
    }
    cout << cur << '\n';
    for (int i = 0; i < cur; i++)
        cout << ans[i].first << ' ' << ans[i].second << '\n';
}

main () {
    boost;
    solve();
    return 0;
}
