#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(){
    ll n;
    cin >> n;
    
    vector<ll>a(n);
    
    for(int i = 0; i < n; i++)
        cin >> a[i];
    
    
    ll cur = 1, last = 0;
    
    vector<pair<ll, ll>> ans;
    
    while(!is_sorted(a.begin(), a.end()) && cur < 32001 && last < n){
        //cout << last << endl;
        
        for(int i = n - 1; i > last; i--){
            if(a[i] == cur){
                ll l = last, r = i;
                reverse(a.begin() + l, a.begin() + r + 1);
                
                ans.push_back({l, r});
                last++;
            }
        }
        cur++;
    }
    cout << ans.size() << endl;
    
    for(auto i: ans)
        cout << i.first + 1 << ' ' << i.second + 1 << endl;
    
    
    return 0;
}
