#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define st string
#define pb push_back
#define rt return
#define rv reverse
#define sr sort
#define si size()
#define en end()
#define be begin()
#define sc second
#define fr first
#define vl vector < ll >
#define vvl vector < vector < ll > >
#define vs vector < st >
#define vvs vector < vector < st > >
#define pall pair < ll , ll >
#define pasl pair < st , ll >
#define pals pair < ll , st >
using namespace std;

int main()
{
    fast;
    ll n;
    cin >> n;
    ll a[n+2],b[n+2];
    for (int i=0;i<n;++i)
    {
        ll x;
        cin >> x;
        --x;
        a[x]=i;
        b[i]=x;
    }
    vl v1,v2;
    for (int i=0;i<n;++i)
    {
    if (a[i]!=i)
    {
        v1.pb(a[i]);
        v2.pb(i);
        ll x=a[i];
        for (int j=0;j<(x-i+1)/2;++j)
        {
            ll x1,x2;
            x1=b[i+j];
            x2=b[x-j];
            b[i+j]=x2;
            b[x-j]=x1;
            a[x1]=x-j;
            a[x2]=i+j;
        }
    }
    }
    cout << v1.si << "\n";
    for (int i=0;i<v1.si;++i)
        cout << v2[i]+1 <<" " << v1[i]+1 << "\n";

}
