#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define pb push_back
typedef long long ll;

const int nmax=200010;

tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ost;

int mas[nmax]={0};
vector<pair<int,int>> ans;

void fun(int l,int r) {
    reverse(mas+l,mas+r+1);
    ans.pb({l,r});
    return ;
}

int main()
{
    //ios_base::sync_with_stdio(0);
    //cin.tie(0);
    int n,ind;
    cin >> n;
    for(int i=1;i<=n;i++) {
        cin >> mas[i];
    }
    for(int i=1;i<=n;i++) {
        ind=i;
        for(int j=i;j<=n;j++) {
            if(mas[ind]>mas[j]) {
                ind=j;
            }
        }
        if(i!=ind) {
            fun(i,ind);
        }
    }
    cout << ans.size() << "\n";
    for(auto i:ans) {
        cout << i.first << " " << i.second << "\n";
    }
    return 0;
}
