#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define int long long
#define mp make_pair
#define pb push_back

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

constexpr int INF = (int)1e18;
constexpr int N = (int)2e5 + 111;
constexpr int md = (int)998244353;

vector<int> g[N];
vector<int> additional[N];

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

set<int> pos[32222];

void solve(){
    int n;
    cin >> n;
    vector<int> v(n+1,0);
    for(int i = 1; i <= n; i++){
        cin >> v[i];
    }
    vector<int> t = v;
    sort(t.begin(),t.end());

    vector<pair<int,int>> ans;

    for(int i = 1; i <= n; i++){
        if(t[i] == v[i])
            continue;
        int p = -1;
        vector<int> k;
        for(int j = i+1; j <= n; j++){
            if(v[j] == t[i]){
                k.pb(j);
            }
        }
        int P = rnd()&1;
        p = (P ? k.back() : k[0]);
        reverse(v.begin()+i,v.begin()+p+1);
        ans.pb(mp(i,p));
    }

    cout << ans.size() << "\n";
    for(auto&[x,y] : ans)
        cout << x << " " << y << "\n";

    return;
}

signed main(){
    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    int tests = 1;
//    cin >> tests;
    for(int test = 1; test <= tests; test++){
        solve();
    }
    return 0;
}
/**
make VUDOI great again.

abcaabbaccccb
5
1 13
2 8
1 9
4 12
4 7

5 6
2 4 6 4 1 5
2 4 5 1 3 5
1 6 1 2 3 6
3 6 5 5 1 2
4 3 4 2 3 6

1 2 4 4 5 6
1 2 3 4 5 5
1 1 2 3 6 6
1 2 3 5 5 6
2 3 3 4 4 6

5
2 4 3 5 1

1 5 3 4 2
1 2 4 3 5
1 2 3 4 5

**/
