#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <cstdio>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <cstring>
#define endl '\n'

using namespace std;
typedef long long ll;


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ll n;
    cin >> n;
    
    vector<ll>a(n);
    
    for(int i = 0; i < n; i++)
        cin >> a[i];
    
    vector<ll> mp(32007);
    for(int i = 0; i < n; i++)
        mp[a[i]] = i  + 1;
    
    vector<pair<ll, ll>> ans;
    
    for(int i = 1; i <= n; i++){
        if(mp[i] == i)
            continue;
        
        ans.push_back({min((ll)i, mp[i]), max(mp[i], (ll)i)});
        
        
        ll len = abs(i - mp[i]) + 1;
        ll finish = mp[i];
        
        for(int j = i; j <= finish; j++){
            //cout << j << ' ' << i - 1 << ' ' << len << ' ' << mp[j] << endl;

            mp[j] = len - (mp[j] - (i - 1)) + 1 + (i - 1);
            
        }
        
    }
    
    cout << ans.size() << endl;
    
    for(auto i: ans)
        cout << i.first << ' ' << i.second << endl;
    cout << endl;
    
    return 0;
}
