#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<pair<int,int>> E;
vector<pair<int,int>> E2;
int ptr[100007];
int in[100007];
int out[100007];
int N;
vector<int> G[100007];
deque<int> Q;
int used[100007];
ll tim;
int a[100007];
inline void solve(){
    int n;
    cin >> n;
    vector<pair<int,int>> P;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        pair<int,int> A = {10000000,-1};
        for (int j = i; j < n; ++j) {
            A = min(A,{a[j],j});
        }
        int it = A.second;
        if(i == it) continue;
        P.push_back({i,it+1});
        reverse(a+i,a+it+1);
    }
    cout << P.size() << "\n";
    for (int i = 0; i < P.size(); ++i) {
        cout << P[i].first+1 << " " << P[i].second << "\n";
    }
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    //cin >> t;
    while (t--) solve();
    return 0;
}


// D - ейлеровый цикл -80 балов
