#include <bits/stdc++.h>

using namespace std;

int n;
int a[101010];
int b[101010];
vector<pair<int, int> > ans;
int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b + 1, b + 1 + n);
    for (int i = n; i >= 1; i--) {
        for (int j = i; j >= 1; j--) {
            if (b[i] == a[j]) {
                if (i == j)break;
                ans.push_back({j, i});
                reverse(a + j, a + i + 1);
                break;
            }
        }
//        for (int j = 1; j <= n; j++)
//            cout << a[j] << " ";
//        cout << endl;
    }
    cout << ans.size() << '\n';
    for (int i = 0; i < ans.size(); i++)
        cout << ans[i].first << " " << ans[i].second << '\n';
}
/**
5
2 4 3 5 1
1 5 3 4 2
1 2 4 3 5
1 2 3 4 5
*/
