#include <iostream>

using namespace std;

int main()
{
    int n,minn,i,c,numb,x,step,j,k,y,kil;
    cin >> n;
    kil=1;
    int a[32005];
    minn=32005;
    step=1;
    int b [1000];
    for (i=1; i<=n; ++i)
    {
        cin >> a[i];
    }
    while (step<=n)
    {
        minn=32005;
        numb=0;
        for (i=step; i<=n; ++i)
        {
            if (minn>a[i])
            {
                minn=a[i];
                numb=i;
                //cout << numb << "=" << endl;
            }
        }
        if (numb!=step)
        {
            b[kil]=step;
            b[kil+1]=numb;
            kil=kil+2;
            x=numb;
            c=0;
            k=0;
            if (numb-step==1)
                y=1;
            else
            {
                if ((numb-step) % 2 ==1)
                    y=(numb-step)/2+1;
                else
                    y=(numb-step)/2;
            }
            for (i=1; i<=y; ++i)
            {
                c=a[step+i-1];
                a[step+i-1]=a[x-k];
                a[x-k]=c;
                ++k;
            }
                //cout << y << "=" << endl;
        }


        /*for (i=1; i<=n; ++i)
        {
            cout << a[i] << " ";
        }
        cout << endl;*/
        ++step;
    }
    cout << kil/2 << endl;
    for (i=2; i<=kil; i=i+2)
        cout << b[i-1] << " " << b[i] << endl;


    return 0;
}
