#include <iostream>
#include <map>
#include <vector>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <climits>
#include <ctime>
#include <iomanip>
#include <string>

using namespace std;

map<int,int> mp;
map<int,int> ind;
    
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin>>n;
    vector<int> a(n);
    vector<int> p;
    int b[n+1];
    for(int i = 0; i < n; i++)
    {
        cin>>b[i];
        p.push_back(b[i]);
    }
    sort(p.begin(), p.end());
    if(p == a) 
    {
        cout<<0;
        return 0;
    }
    vector <pair<int,int>> res;
    for(int i = 0; i < n; i++)
    {
        for(int j = i; j < n - 2; j++)
        {
            {
                int l = j, r = j;
                while(b[r + 1] < b[r])
                {
                    r++;
                    if(r == n - 1) break;
                }
                if(r - l > 0)
                {
                    res.push_back({l, r});
                    for(int k = l; k < (l+r)/2; k++)
                    {
                        swap(b[k], b[r - (k - l)]);
                    }
                }
            }
        }
    }
    cout<<res.size()<<'\n';
    for(auto to:res)
    {
        cout<<to.first + 1<<" "<<to.second + 1<<'\n';
    }
}