#include <iostream>
#include <bits/stdc++.h>

#define int long long
#define endl '\n'
#define inf 2000000000000000000
#define random (rand()^(rand()<<15))

using namespace std;
constexpr int mod=1000000007;
constexpr int MOD=998244353;

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];
    }
    vector<pair<int,int>>v;
    v.reserve(1000);
    sort(b,b+n);
    for(int i=0;i<n;i++)
    {
        for(int j=n-1;j>i;j--)
        {
            if(a[j]==b[i])
            {
                reverse(a+i,a+j+1);
                v.push_back({i+1,j+1});
                break;
            }
            if(b[j]==a[i])
            {
                reverse(a+i,a+j+1);
                v.push_back({i+1,j+1});
                continue;
            }
        }
    }
    // for(int i=0;i<n;i++)
    // {
    //     cout<<a[i]<<" ";
    // }
    cout<<v.size()<<endl;
    for(auto&[x,y]:v)
    {
        cout<<x<<" "<<y<<endl;
    }
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t=1;
//    cin>>t;
    for(int _=1;_<=t;_++)
    {
        solve();
    }
}
