#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
mt19937 rnd(time(nullptr));
void solve()
{
    int n;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b,b+n);
    vector<pair<int,int>>v;
    for(int i=n-1;i>=0;i--)
    {
        if(a[i]!=b[i])
        {
            vector<int>q;
            for(int j=n-1;j>i;j--)
            {
                if(a[j]==b[i])
                {
                    q.push_back(j);
                }
            }
            int j=q[rnd()%q.size()];
            v.push_back({i+1,j+1});
            reverse(a+i,a+j+1);
        }
    }
    cout<<v.size()<<endl;
    for(auto [q,w]:v)cout<<q<<' '<<w<<endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cout.tie(nullptr);cin.tie(nullptr);
    solve();
}
