#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;

    vector<int> a(n);
    for ( auto& el : a )
        cin >> el;

    vector< pair<int,int> > ans;

    for ( int i=n-1; i>=0; i-- )
    for ( int j=0; j < i; j++ )
    if ( a[j] > a[j+1] )
    {
        ans.push_back({ j+1, j+2 });
        swap( a[j], a[j+1] );
    }

    cout << ans.size() << '\n';

    for ( auto& [x,y] : ans )
        cout << x << ' ' << y << '\n';

    return 0;
}
