#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    scanf("%d", &a[i]);
  vector<int> saveA = a;
  int kol = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n - 1; j++) {
      if (a[j] > a[j + 1])
        swap(a[j], a[j + 1]), kol++;
    }
  }
  printf("%d\n", kol);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n - 1; j++) {
      if (saveA[j] > saveA[j + 1]) {
        swap(saveA[j], saveA[j + 1]);
        printf("%d %d\n", j + 1, j + 2);
      }
    }
  }
}
