//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define ull unsigned ll
#define ff first
#define ss second
//#define int long long
#define int short
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb push_back
#define pii pair <int, int>
using namespace std;
using namespace __gnu_pbds;
template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
const ll inf = 1e18;
constexpr ll mod = 998244353;
const int MAXN = 1e5+10;

void solve(){
	int n;
	cin >> n;
	vector <int> a(n+1);
	for (int i = 1; i <= n; ++i) cin >> a[i];
	
	vector <pii> ans;
	while (n > 1){
		for (int i = 2; i <= n; ++i){
			if (a[i] < a[i-1]){
				swap(a[i], a[i-1]);
				ans.pb({i-1, i});
			}
		}
		--n;
	}
	cout << ans.size() << '\n';
	for (auto i : ans) cout << i.ff << " " << i.ss << '\n';
}
 
signed main(){
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    solve();
}