#include <bits/stdc++.h>
using namespace std;

int main() {
    long long n;
    cin>>n;
    long long A[n];
    long long B[n];
    vector<long long>ans;
    for(int i=0;i<n;i++){
        cin>>A[i];
        B[i]=A[i];
    }
    sort(B,B+n);
    /*/
    reverse(B+3,B+4);
    for(int i=0;i<n;i++){
        cout<<B[i]<<" ";
    }/*/
    for(int i=0;i<n;i++){
        for(int j=i;j<n;j++){
            if(B[i]==A[j] && i!=j){
                //cout<<i<<" "<<j<<endl;
                reverse(A+i,A+j+1);
                ans.push_back(i+1);
                ans.push_back(j+1);
                break;
            }
        }/*/
        for(int i=0;i<n;i++){
             cout<<A[i]<<" ";
        }
        cout<<endl;/*/
    }
    
    
    /*/for(int i=0;i<n;i++){
        cout<<A[i]<<" ";
    }/*/
    cout<<ans.size()/2<<endl;
    for(int i=0;i<ans.size();i+=2){
        cout<<ans[i]<<" "<<ans[i+1]<<endl;
    }
    
    
}
