#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]);
        ind[b[i]] = 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++)
    {
        int x;
        //cout<<p[i]<<" "<<b[i]<<'\n';
        if(b[i] != p[i])
        {
            for(int j = i; j < n; j ++)
            {
                if(b[j] == p[i])
                {
                    x = j;
                }
            }
            res.push_back({i, x});
            for(int j = i; j <= (i + x) / 2;  j++)
            {
                swap(b[j], b[x - (j - i)]);
            }
        }
    }
    cout<<res.size()<<"\n";
    for(auto i : res)
    {
        cout<< i.first + 1<<" "<<i.second + 1<<'\n';
    }
}