#include <bits/stdc++.h>

using namespace std;

#define fr first
#define sc second

typedef long long ll;
typedef pair<ll,ll> pll;
const ll INF = 100000000007, DIM = 32007, MAXN = 100000;

ll tt, a[DIM], b[DIM], pos[DIM], cnt[DIM], pos2[DIM], t[DIM], v,u,n,m,res, l, r;
string s;
vector<pll> actions;

void solve(){
	cin>>n;
    for(int i=1;i<=n;++i){
        cin>>a[i];
        pos[a[i]]=i;
    }
    for(int i=1;i<=n;++i){
        if(i==pos[i])continue;
        actions.push_back({i, pos[i]});
		reverse(a+i,a+pos[i]);
        for(int j=1;j<=n;++j)pos[a[j]]=j;

    }
    cout<<actions.size()<<'\n';
    for(auto u : actions){
        cout<<min(u.fr,u.sc)<<" "<<max(u.fr,u.sc)<<'\n';
    }
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	tt=1;
	//cin>>tt;
	while(tt--)
		solve();
	return 0;
}