#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
const ll DIM = 1e5+7;
const ll INF = 1000000000007;

ll n,a[DIM],q;
string s;
priority_queue< pll, vector<pll>, greater<ll> > Q;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> a[i];
    }

    vector<pll> ans;

    for(int i=1;i<=n;i++){
        ll least = INF;
        ll pos;
        for(int j=i;j<=n;j++){
            if(a[j]<least){
                pos = j;least = a[j];
            }
        }
        if(pos==i)continue;

        ans.push_back({i,pos});
        reverse(a+i,a+1+pos);
    }

    cout << ans.size() << endl;
    for(auto [to,e]:ans)
        cout << to << ' ' << e << endl;



    return 0;
}
