#include <bits/stdc++.h>
using namespace std;
const int N = 1123;
int a[N], b[N], n, tot, stk[N * N][2];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), b[i] = i;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n - 1; j++)
      if (a[j] > a[j + 1])
        swap(a[j], a[j + 1]), ++tot, stk[tot][0] = b[j], stk[tot][1] = b[j + 1],
                                     swap(b[j], b[j + 1]);
  printf("%d\n", tot);
  while (tot) printf("%d %d\n", stk[tot][0], stk[tot][1]), --tot;
  return 0;
}
