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

Solution 1 (runtime: 1234 ms):
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
#define int long long
using namespace std;
const int mod=998244353;
int ispri(int b){
	int k=(int)sqrt(b);
	if(b==2)
		return 1;
	for(int i=2;i<=k;i++){
		if(b%i==0){
			return 0;
		}
	}
	return 1;
}
ll ou(ll a,ll b){
	return (a%b==0)?b:ou(b,a%b);
}
ll max(ll a,ll b){
	if(a>b){
		return a;
	}
	return b;
}
ll min(ll a,ll b){
	if(a<b){
		return a;
	}
	return b;
}
int fac[3000001];
int fac1[3000001];
void exgcd(int a,int b,int& d,int& x,int& y){
	if(a%b==0){
		d=b;
		x=0;
		y=1;
		return;
	}
	exgcd(b,a%b,d,y,x);
	y-=(a/b)*x;
}
int rev(int k){
	int d,x,y;
	exgcd(k,mod,d,x,y);
	return (x+1000000*mod)%mod;
}
void init(){
	fac[0]=1;
	fac1[0]=1;
	for(int i=1;i<=3e6;i++){
		fac[i]=fac[i-1]+i;
	}
	for(int i=1;i<=3e6;i++){
		fac[i]=i*fac[i-1];
		fac[i]%=mod;
		fac1[i]=rev(fac[i]);
	}
}
int pri[100000]={0};
bool vis[1000000]={0};
void getpri(){
  int cnt=0;
  for(int i=2;i<1000000;i++){
    if(vis[i]==0){
      pri[cnt]=i;
      cnt++;
    }
    for(int j=0;j<cnt;j++){
      if(i*pri[j]>=1000000)
        break;
      vis[i*pri[j]]=true;
      if(i%pri[j]==0)
        break;
    }
  }
  return ;
}
int forpow(ll a,ll n){
    ll ret=1;
    while(n!=0){
        if((n&1)==1){
            ret*=a;
            ret%=mod;
        }
        a*=a;
        a%=mod;
        n>>=1;
    }
    return ret;
}
map<int,int> div(int x){
  map<int,int> ret;
  for(int i=2;;i++){
    if(i>sqrt(x)){
      if(x!=1){
        ret[x]++;
      }
      break;
    }
    if(vis[i])
      continue;
    while(x%i==0){
      ret[i]++;
      x/=i;
    }
  }
  return ret;
}
int c(int a,int b){
	return (((fac[a]*fac1[a-b])%mod)*fac1[b])%mod;
}
int sta[501];
void ini(){
	sta[1]=1;
	for(int i=2;i<=500;i++){
		sta[i]=sta[i-1]+i*((i*i)-((i-1)*(i-1)));
	}
}
int ipow(int a,int n){
	ll ret=1;
    while(n!=0){
        if((n&1)==1){
            ret*=a;
        }
        a*=a;
        n>>=1;
    }
    return ret;
}
int phi[1000000];
void calphi(){
	int cnt=0;
	phi[0]=0;
	phi[1]=1;
	phi[2]=1;
  for(int i=2;i<1000000;i++){
    if(vis[i]==0){
      pri[cnt]=i;
      phi[i]=i-1;
      cnt++;
    }
    for(int j=0;j<cnt;j++){
      if(i*pri[j]>=1000000)
        break;
      vis[i*pri[j]]=true;
      phi[i*pri[j]]=phi[i]*phi[pri[j]];
      if(i%pri[j]==0){
      	phi[i*pri[j]]=i*pri[j]-i;
        break;
      }
    }
  }
  return ;
}
void solve() {
	int n;
	cin>>n;
	vector<int> v(n);
	vector<int> pos(n+1);
	for(int i=0;i<n;i++){
		int t;
		cin>>t;
		v[i]=t;
		pos[t]=i;
	}
	vector<int> rig(n);
	vector<int> rigpos(n+1);
	for(int i=0;i<n;i++){
		rig[i]=i+1;
		rigpos[i+1]=i;
	}
	vector<pair<int,int>> ans;
	map<int,int> m;
	for(int i=0;i<n;i++){
		int tar=v[i];
		int p=rigpos[tar];
		while(p!=n-1){
			int tem=rig[p+1];
			rig[p+1]=rig[p];
			rig[p]=tem;
			rigpos[rig[p]]=p;
			rigpos[rig[p+1]]=p+1;
			ans.push_back(make_pair(rig[p],rig[p+1]));
			p++;
		}
		while(p!=i){
			int tem=rig[p-1];
			rig[p-1]=rig[p];
			rig[p]=tem;
			rigpos[rig[p]]=p;
			rigpos[rig[p-1]]=p-1;
			ans.push_back(make_pair(rig[p-1],rig[p]));
			p--;
		}
	}
	cout<<ans.size()<<endl;
	for(auto g:ans){
		cout<<g.fi<<' '<<g.se<<endl;
	}


}
signed main(){
	cout.flush();
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//cout<<fixed<<setprecision(6);
	int x;	
	// init();
	// calphi();
	// cin>>x;
	x=1;
	while(x--){
		solve();
	
	}
}

Solution 2 (runtime: 1234 ms):
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define fl(n) for (ll i=0; i < n; i++)
#define st(v) sort(v.begin(),v.end())
#define pb push_back
#define el '\n'
#define mod 998244353

ll mod_inverse(ll a,ll m) {
    ll res=1,p=m - 2;
    while (p > 0) {
        if (p & 1) res=(res * a)%m;
        a=(a * a)%m;
        p >>= 1;
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
    while (t--) {
        int n;cin>>n;vll v(n);fl(n){cin>>v[i];} vpll ans;
        vll x(n);fl(n){x[i]=i+1;}
        for(int i=n-1;i>=0;i--){
           
            bool found=false;int a;
            for(int j=n-1;j>=0;j--){
                 if(found){
                    // cout<<v[i]<<" "<<x[j]<<endl;
                    ans.pb(make_pair(v[i],x[j]));
                 }
                 if(x[j]==v[i]&& !found){found=true;a=j;}
            }
            
          x.erase(x.begin()+a);
          x.insert(x.begin(),v[i]);
           

            }
            cout<<ans.size()<<endl;
            fl(ans.size()){cout<<ans[i].first<<" "<<ans[i].second<<endl;}

        }
      
    
    return 0;
}