#include <bits/stdc++.h>
using namespace std;
short getIndex(vector<short> v, short b, short number) {
    auto index = find(v.begin() + b, v.end(), number);
    if (index != v.end()) 
        return index - v.begin();
    else
        return -1;
}
int main() {
    short n;
    cin >> n;
    long long amount = 0;
    vector<short> v1;
    v1.resize(n);
    for (short i = 0; i < n; i++)
        cin >> v1[i];
    vector<short> v2 = v1;
    sort(v2.begin(), v2.end());
    vector<short> l;
    vector<short> r;
    for (short i = 0; i < n; i++) {
        if (v1[i] == v2[i])
            continue;
        else {
            short number = getIndex(v1, i, v2[i]);
            reverse(v1.begin() + i, v1.end() - v1.size() + number + 1);
            amount++;
            l.push_back(i);
            r.push_back(number);
        }
    }
    cout << amount << endl;
    for (long long i = 0; i < amount; i++)
        cout << l[i] + 1 << ' ' << r[i] + 1 << endl;
}