#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;

#define sz(x) (int)(x).size()
#define ins insert
#define pb push_back
#define ff first
#define ss second
#define bust ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define nl '\n'

int main()
{
    bust
    ll n, ans = 0;
    cin >> n;
    vl vec(n);
    vector<pair<ll, ll>> res;
    for(int i = 0; i < n; i++){
        cin >> vec[i];
    }
    vl dif = vec;
    sort(dif.begin(), dif.end());
    bool used[n] = {false};
    for(int tek = 1; tek <= n; ++tek){
        ll exp = dif[tek-1]; // expected ai
        ll cnt = 0;
        for(int i = 0; i < n; i++){
            if(used[i])continue;
            if(vec[i] == exp){
                used[i] = 1;
                ll l = tek, r = l+cnt;
//                cout << i << " " << l << " " << r << '\n';
                if(cnt==0){
                    break;
                }
                res.pb({l, r});
                ans++;
                if(r != l+1){
                    res.pb({l+1, r});
                    ans++;
                }
                break;
            }
            else{
                cnt++;
            }

        }
    }
    cout << ans << '\n';
    for(auto e: res){
        cout << e.ff << " " << e.ss << '\n';
    }
    return 0;
}

