#include<bits/stdc++.h>
#define ff first
#define ss second
using namespace std;
long long n,m,i,j,k,l,p,q,r,g,h,a[1000009],b[100009],ans,cnt;
vector < pair <long long, long long> > v;
map <long long ,long long> mp;
vector <long long> pa;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for(i=1;i<=n;i++)
    {
        cin >> a[i];
        b[i]=a[i];
    }
    sort(b+1,b+n+1);
    for(i=1;i<=n;i++)
    {
       cnt=b[i];
       for(j=1;j<=n;j++)
       {
           if (a[j]==cnt)
           {
               if (i==j)
               {

               }
               else
               {
                   v.push_back({i,j});
                   reverse(a+i,a+j+1);
               }

               j=n;
           }
       }
//       for(l=1;l<=n;l++)
//       {
//           cout << a[l] << " ";
//       }
//       cout << "\n";
    }
    cout << v.size() << "\n";
    for(i=0;i<v.size();i++)
    {
        cout << v[i].ff << " " << v[i].ss << "\n";
    }
}
