#include <bits/stdc++.h>
#define fr(i,x,y) for(int i=x;i<y;i++)
#define rfr(i,x,y) for(int i=x;i>=y;i--)
#define int long long

using namespace std;

const int N=1e6;
void solve()
{
  int n;
  cin>>n;
  vector<int> mas(n);
  fr(i,0,n)cin>>mas[i];
  vector<pair<int,int>> ans;
  bool can = true;
  while(can)
  {
    can = false;
    fr(i,1,n)
    {
      if(mas[i]>mas[i-1])
      {
        ans.push_back({i, i + 1});
        swap(mas[i],mas[i-1]);
        can = true;
      }
    }
  }
  cout<<ans.size()<<'\n';
  for(auto j:ans)
  {
    cout<<j.first<<' '<<j.second<<'\n';
  }
}

signed main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  int t=1;
  while(t--)solve();
}
/*
2 4 3 5 1
1 5 3 4 2
1 2 4 3 5
1 2 3 4 5
*/