#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <cstdio>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <cstring>
#define endl '\n'

using namespace std;
typedef long long ll;



int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ll n;
    cin >> n;
    
    vector<ll>a(n);
    for(int i = 0; i < n ;i++)
        cin >> a[i];
    
    vector<pair<ll, ll>> ans;
    
    ll mx = -1;
    vector<ll>mp(32007);
    
    for(auto i: a){
        mx = max(mx, i);
        mp[i]++;
    }
    
    for(int i = 1; i <= mx && !is_sorted(a.begin(), a.end()); i++){
        if(mp[i] == 0)
            continue;
        ll pos = 0;
        
        for(int j = i; j < n; j++)
            if(a[j] == i)
                pos = j;
        
        ans.push_back({i, pos + 1});
        reverse(a.begin() + i - 1, a.begin() + pos + 1);

    }
    
    cout << ans.size() << endl;
    
    for(auto i: ans)
        cout << i.first << ' ' << i.second << endl;
    
    return 0;
}
