Problem: 2052A - Adrenaline Rush
Language: c++17 

Solution 1 (runtime: 1311 ms):
#include <bits/stdc++.h>

#ifndef LOCAL
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#endif
#define COPYRIGHT "Copyright (c) 2024 ,yzn. All rights Reserved."
#define longbi xjn
#define AUTHOR yzn
#define YEAR 2025
#define kzn yzn

#define inf (1ll<<60)

#define fori(i, n) for (int i = 1; i <= n; i++)
#define ford(i, n,m) for (int i = n; i > m; i--)

#define ll long long
#define int ll

#define clr(n,m) for(int i=0;i<=m;i++)n[i]=0;
#define sinf(n,m) for(int i=0;i<=m;i++)n[i]=inf;

#define vi vector<int>
#define pi pair<int, int>
#define vpi vector<pair<int, int>>
#define fi first
#define se second

constexpr double eps=1e-6;
constexpr bool debug=0;
#define ID if(debug)
char abt[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };
using namespace std;
namespace IO{
	char ibuf[(1<<20)+1],*iS,*iT;
	#ifndef LOCAL
	#define gh() (iS==iT?iT=(iS=ibuf)+fread(ibuf,1,(1<<20)+1,stdin),(iS==iT?EOF:*iS++):*iS++)
 	#else
	#define gh() getchar()
	#endif
	inline long long read(){char ch=gh();long long x=0;bool t=0;while(ch<'0'||ch>'9')   t|=ch=='-',ch=gh();while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=gh();return t?-x:x;}
	inline void write(int x){static int sta[35];int top = 0;do{sta[top++] = x % 10, x /= 10;} while (x);while (top)putchar(sta[--top] + 48);}
	const void File(bool b1,bool b2){if(b1)freopen("out.out","w",stdout);if(b2)freopen("in.in","r",stdin);}
	void YN(bool b){if(b)puts("Yes");else puts("No");}
}
using namespace IO;
const int N=1e3+5;
int n,A[N],C[N],wp[N][N];
pi B[N];
/*
冒泡排序...没有交换的对子互相交换一下.
*/
vector<pi>opt;
signed main()
{
    n=read();
    for(int i=1;i<=n;i++)A[i]=read(),C[A[i]]=i;
    
    /*for(int i=1;i<=n;i++){
        for(int j=1;j<n;j++){
            if(A[j]>A[j+1])opt.push_back({A[j],A[j+1]}),swap(A[j],A[j+1]);
        }
    }*/
    for(int i=1;i<=n;i++)B[i]={i,C[i]};
    for(int i=1;i<=n;i++){
        for(int j=1;j<n;j++){
            if(B[j].se>B[j+1].se)opt.push_back({B[j+1].fi,B[j].fi}),wp[B[j+1].fi][B[j].fi]=wp[B[j].fi][B[j+1].fi]=1,swap(B[j],B[j+1]);
            else if(!wp[B[j].fi][B[j+1].fi])opt.push_back({B[j+1].fi,B[j].fi}),swap(B[j],B[j+1]);
        }
    }
    for(int i=1;i<n;i++){
        if(!wp[A[i]][A[i+1]])opt.push_back({A[i+1],A[i]}),opt.push_back({A[i],A[i+1]});
    }
    cout<<opt.size()<<endl;
    for(pi j:opt)cout<<j.first<<' '<<j.second<<endl;
}
//standard template
/*
1 2 3 4
2 1 3 4
2 1 4 3
2 4 1 3
4 2 1 3
4 2 3 1
4 2 1 3

1 2 3 4
1 3 2 4
1 3 4 2
1 4 3 2

*/


Solution 2 (runtime: 296 ms):
#include <iostream>
#include <bits/stdc++.h>
#include <utility>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef unsigned long long ull;
typedef long double lld;
#define rep(n) for (int i = 0; i < n; i++)
#define repi(n) for (int j = 0; j < n; j++)
#define loop(i, n1, n2) for (int i = n1; i < n2; i++)
#define rloop(i, n1, n2) for (int i = n1; i >= n2; i--)
#define rev(n) for (int i = n - 1; i >= 0; i--)
#define autor(x) for (auto i : x)
#define mod 1000000007
#define nline "\n"
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x <<" "; _print(x); cerr << endl;
#else
#define debug(x)
#endif
void init_code(){ 
  #ifndef ONLINE_JUDGE 
    freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);freopen("Error.txt", "w", stderr);
  #endif //ONLINE JUDGE
}
void _print(ll t) {cerr << t;}
void _print(int t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(lld t) {cerr << t;}
void _print(double t) {cerr << t;}
void _print(ull t) {cerr << t;}
template <class T, class V> void _print(pair <T, V> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T, class V> void _print(map <T, V> v);
template <class T> void _print(multiset <T> v);
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.ff); cerr << ","; _print(p.ss); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}
long long lcm(int a, int b){return (a / __gcd(a, b)) * b;}
int getRandomNumber(long long lb, long long ub){return ((rand() % (ub - lb + 1)) + lb);}
int getNewRandomNumber(int l, int u, vector<bool> &vis){int x = getRandomNumber(l, u);if (vis[x])return getNewRandomNumber(l, u, vis);return x;}
ll expo(ll a, ll b, ll m){ll res = 1;while (b > 0){if (b & 1) res = (res * a) % m;a = (a * a) % m;b = b >> 1;}return res;}
ll mod_add(ll a, ll b, ll m){a = a % m;b = b % m;return (((a + b) % m) + m) % m;}
ll mod_mul(ll a, ll b, ll m){return ((a % m) * (b % m)) % m;}
ll mod_sub(ll a, ll b, ll m){a = a % m;b = b % m;return (((a - b) % m) + m) % m;}
ll mminvprime(ll a, ll m){return expo(a, m - 2, m);}
void factandifact(vector<ll> &fact, vector<ll> &ifact, ll n, ll m){fact[0] = 1;for (int i = 1; i <= n; i++) fact[i] = mod_mul(fact[i - 1], i, m);ifact[n] = mminvprime(fact[n], m);for (int i = n - 1; i >= 0; i--) ifact[i] = mod_mul(ifact[i + 1], i + 1, m);}
ll combination(ll n, ll r, ll m, vector<ll> &fact, vector<ll> &ifact){return mod_mul(n, mod_mul(ifact[r], ifact[n - r], m), m);}
ll combination(ll n, ll r, ll m){ll nfact = 1;for (ll i = n; i > n-r; i--)nfact = mod_mul(nfact, i, m);ll rfact = 1;for (int i = 2; i <= r; i++)rfact = mod_mul(rfact, i, m);rfact = mminvprime(rfact, m);return mod_mul(nfact,rfact,m);}
void dfs_binary_lifting(int node, int par, vector<vector<int>> &adj,vector<int> &level,vector<int> &parent,int l = 0){level[node] = l; parent[node] = par; for(int j:adj[node]){if(j!=par){dfs_binary_lifting(j,node,adj,level,parent,l+1);}}}
void binary_lifting(vector<int> &parent,vector<vector<int>> &dp,int n){rep(n+1){dp[0][i] = parent[i];} int se = dp.size(); for(int i=1;i<se;i++){for(int j=1;j<=n;j++){if(dp[i-1][j]!=-1){dp[i][j] = dp[i-1][dp[i-1][j]];}}}}
int kthparent(int a,int k,vector<vector<int>> &dp){int pos = 0; while(k>0){if(k&1) a = dp[pos][a]; k = k>>1; pos++;} return a;}
int lca(int a,int b,vector<int> &level,vector<vector<int>> &dp){if(level[a]<level[b]) swap(a,b); a = kthparent(a,level[a]-level[b],dp); if(a==b) return a; rloop(i,dp.size()-1,0){if(dp[i][a]!=dp[i][b]){a = dp[i][a]; b = dp[i][b];}} return dp[0][a];}
// vector<int> level(n+1,0),parent(n+1,0);
// dfs_binary_lifting(1,0,adj,level,parent);
// vector<vector<int>> dp(log2(n)+1,vector<int>(n+1,-1));
// binary_lifting(parent,dp,n);

int main()
{
    init_code();
    int n;
    cin>>n;
    vector<int> a(n),per(n);
    rep(n) {
        cin>>a[i];
        per[i] = i+1;
    }
    vector<pair<int,int>> ans;
    vector<bool> vis(n+1,false);
    for(int i=0;i<n;i++){
        int ind = find(all(per),a[i]) - per.begin();
        for(int j = ind;j<n-1;j++){
            ans.push_back({per[j+1],per[j]});
            swap(per[j],per[j+1]);
        }
        for(int j=n-1;j>i;j--){
            ans.push_back({per[j],per[j-1]});
            swap(per[j],per[j-1]);
        }
    }
    int m = ans.size();
    cout<<m<<nline;
    for(auto j:ans){
        cout<<j.first<<" "<<j.second<<nline;
    }
    return 0;
}