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

int main()
{
    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=1; j<=n; j++)
        {
            //cout<<i<<" "<<j<<endl;
            //cout<<b[i]<<" "<<a[j]<<endl;
           /* for (int h=1; h<=n; h++)
                cout<<a[h]<<" ";
            cout<<endl;*/
            if (b[i]==a[j] and i!=j)
            {
                l.push_back(min(i, j));
                r.push_back(max(i, j));
                reverse(a+min(i, j), a+max(i, j)+1);
                i=1;
                j=1;
            }
        }
    }
    cout<<l.size()<<endl;
    for (int i=0; i<l.size(); i++)
    cout<<l[i]<<" "<<r[i]<<endl;

}
