#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

#define pii pair<int, int>
#define S second
#define F first
#define pb push_back

using namespace std;

typedef long long ll;

void solve (){
  ll n;
  cin >> n;
  vector <int> v(n);
  for (int i = 0; i < n; i++){
    cin >> v[i];
  }
  
  vector <pii> rez;

  bool sort = false;
  while (!sort){  
    sort = true;
    for (int j = 0; j < n-1; j++){
      if (v[j] > v[j+1]) {
        swap(v[j], v[j+1]);
        sort = false;
        rez.pb({j+1, j+2});
      }
    }
  }
  printf("%d\n", rez.size());
  for (int i = 0; i < rez.size(); i++){
    printf("%d %d\n", rez[i].F, rez[i].S);
  }
  return;
}

int main(){
  solve();

  return 0;
}
