#include <bits/stdc++.h>

using namespace std;
long long n, a[32007], b[32007];
vector<pair<long long, long long>> v;
int main()
{
    cin>>n;
    for(int i = 1; i <= n; i++) cin>>a[i];
    for(int i = 1; i <= n; i++) b[i] = a[i];
    sort(b+1, b+1+n);
    for(int i = 1; i <= n; i++){
        if(a[i] != b[i]){
            for(int j = i+1; j <= n; j++){
                if(a[j] == b[i]){
                    reverse(a+i, a+1+j);
                    v.push_back({i, j});
                    break;
                }
            }
        }
    }
    cout<<v.size()<<endl;
    n = v.size();
    for(int i = 0; i < n; i++) cout<<v[i].first<<' '<<v[i].second<<endl;
    return 0;
}
