#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
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=0;i<n;i++)
    {
        if(a[i]!=b[i])
        {
            for(int j=i+1;j<n;j++)
            {
                if(a[j]==b[i])
                {
                    v.push_back({i+1,j+1});
                    reverse(a+i,a+j+1);
                    break;
                }
            }
        }
    }
    int x=v.size()%2;
    while(v.size()<5120000-x)
    {
        v.push_back({1,n});
    }
    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();
}
