#include <bits/stdc++.h>
using namespace std;
int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    vector < int > mas2;
    vector < pair < int , int > > res;
    int n,a,k=0;
    cin>>n;
    int mas[n];
    for(int i=0;i<n;i++)
    {

        cin>>a;
        mas[i]=a;
        mas2.push_back(a);

        //mas[i]=i;
    }


    sort(mas2.begin(),mas2.end());
    for(int i=0;i<n;i++)
    {
        if(mas[i]==mas2[i])
        {
            continue;
        }
        int in=0;
        for(int j=i+1;j<n;j++)
        {
            if(mas[j]==mas2[i])
            {
                in=j;
                break;
            }
        }
        //cout<<mas2[i]<<" "<<in<<" "<<mas[in]<<"\n";
        reverse(mas+i,mas+in+1);
        k++;
        res.push_back({i+1,in+1});
    }
    //for(int i=0;i<n;i++)
    //{
    //    cout<<mas[i]<<" ";
    //}
    cout<<k<<"\n";
    for(int i=0;i<res.size();i++)
    {
        cout<<res[i].first<<" "<<res[i].second<<"\n";
    }
    return 0;
}
