#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main(){
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    ll n; cin>>n;
     vector <ll> vc(n);

    for(int i = 0; i < n;i++) cin >> vc[i];
    vector<ll> unsortedVC = vc;
    sort(vc.begin(),vc.end());
string result = "";
ll numberOfReverse = 0;
    for(ll i = 0; i<n; i++){
        if(vc[i] != unsortedVC[i]){
            numberOfReverse++;
             auto elementIter = find(unsortedVC.begin(),unsortedVC.end(),vc[i]);
             ll index = distance(unsortedVC.begin(),elementIter);
           result += to_string((i+1)) + " " + to_string((index+1)) + '\n';
           reverse((unsortedVC.begin() + i),(unsortedVC.begin()+(index+1)));
        

        }

    }
 cout << numberOfReverse<< endl;
        cout << result;
}
