#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("inE.txt", "r", stdin);

    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &i : a)
        cin >> i;

    vector<int> b = a;
    sort(b.begin(), b.end());
    vector<pair<int, int>> res;
    for (int i = 0; i < n; i++) {
        int f;
        for (f = i; f < n; f++)
            if (a[f] == b[i])
                break;
        if (f > i) {
            res.push_back({i+1, f+1});
            for (int j = i; j <= f; j++) {
                swap(a[j], a[f - j + i]);
                if (j+1 >= f - (j+1) + i)
                    break;
            }
        }
    }

    cout << res.size() << "\n";
    for (auto i : res) {
        cout << i.first << ' ' << i.second << "\n";
    }

    return 0;
}