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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int a[n+1], b[n+1];
    vector<int> l, r;
    for (int i=1; i<=n; i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b+1, b+n+1);
    for (int i=1; i<=n; i++)
    {
        for (int j=i+1; j<=n; j++)
        {
            if (a[i]>a[j])
            {
               //cout<<endl<<"i j "<<i<<" "<<j<<endl;
                l.push_back(i);
                r.push_back(j);
                for (int h=min(i, j); h<=(i+j)/2; h++)
                {
                    swap(a[h], a[i+j-h]);
                }
               /* for (int h=1; h<=n; h++)
                    cout<<a[h]<<" ";
                cout<<endl;*/
                i=0;
                break;
            }
        }
    }
    cout<<l.size()<<endl;
    for (int i=0; i<l.size(); i++)
        cout<<l[i]<<" "<<r[i]<<endl;
}
