#include <bits/stdc++.h>

using namespace std;

long long reverse_swap(int (&arr)[32000], map<int,int> &pos, int l,int r){
    //cout<<"swap: "<<l<<" "<<r<<"\n";
    int t = r;
    for(int i=l; i<(l+r)/2+1; i++){
        //cout<<i<<" "<<t<<"\n";
        swap(arr[i], arr[t]);
        swap(pos[arr[i]], pos[arr[t]]);
        t--;
    }

    //cout<<"internal sawp: ";
    //for(int i=0; i<5; i++){
    //    cout << arr[i] << " ";
    //}
    //cout<<"\n";
    return r-l+1;
}

int main()
{
    int n;
    long max_el=0, max_el_pos=0, pre_max_el;
    vector<pair<int, int>> swap_arr;
    vector<int> all_numbers;
    map<int, int> pos;

    cin>>n;
    int arr[32000];
    for(int i=0; i<n; i++){
        cin>>arr[i];
        if(arr[i]>=max_el){
            max_el = arr[i];
            max_el_pos = i;
        }
        pos[arr[i]] = i;
        all_numbers.push_back(arr[i]);
    }
    sort(all_numbers.begin(),all_numbers.end());

    reverse_swap(arr, pos, max_el_pos, n-1);
    swap_arr.push_back(make_pair(max_el_pos+1, n));

    //cout<<"first sawp: ";
    // for(int i=0; i<n; i++){
    //    cout << arr[i] << " ";
    //}
    //cout<<"\n";

    for(int i=n-2; i>0; i--){
        max_el = all_numbers[i];
        max_el_pos = pos[max_el];
        //cout<<"current: "<<max_el<<" "<<max_el_pos<<"\n";
        //cout<<"yo: ";
        //for(int i=0; i<n; i++){
        //    cout << arr[i] << " ";
        //}
        //cout<<"\n";
        //for(int k=0; k<i; k++){
        //    if(arr[k] > max_el){
        //        max_el = arr[k];
        //        max_el_pos = k;
        //    }
            //cout<<"Max: "<<max_el<<"\n";
        if(max_el_pos != i){
            reverse_swap(arr, pos, max_el_pos, i);
            swap_arr.push_back(make_pair(max_el_pos+1, i+1));
        }
        //}

    }

    //cout<<"final: ";
    //for(int i=0; i<n; i++){
    //    cout << arr[i] << " ";
    //}
    //cout<<"\n";

    cout<<swap_arr.size()<<"\n";
    for(auto p : swap_arr)
        cout << p.first << " " << p.second << "\n";
}
