#include <bits/stdc++.h>

using namespace std;

#define endl "\n"
#define pb push_back
#define mp make_pair
#define in insert
#define INF 1e9
#define eps 0.0000000001
#define fi first
#define se second
#define y1 yy
#define speedup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef long long ll;

//---------------------------------------|

const int DIM=1e5+7;

ll n,m,l,r;
ll a[DIM];
pair<ll,ll> b[DIM];
vector<pair<ll,ll>> v;

//---------------------------------------|

int main()
{
    speedup;

    cin >> n;

    for (int i=1;i<=n;i++)
    {
        cin >> a[i];
        b[i].fi=a[i];
        b[i].se=i;
    }

    sort(b+1,b+1+n);

    for (int i=1;i<=n;i++)
    {
        a[b[i].se]=i;
    }

    l=1;

    while(l!=n)
    {
        while(a[l]==l&&l!=n)
        {
            l++;
        }
        if (l==n) break;

        ll k=0;
        for (int i=l+1;i<=n;i++)
        {
            if (a[i]==l)
            {
                k=i;
                break;
            }
        }
        v.pb({l,k});
        reverse(a+l,a+1+k);

        l++;
    }

    cout << v.size() << endl;
    for (auto x:v)
    {
        cout << x.fi << " " << x.se << endl;
    }

    return 0;
}
