#include <bits/stdc++.h>
int n, a[1001], b[1001], st[1001], tp;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
    b[i] = i;
  }
  int ans = 0;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      if (a[j] < a[i]) ans++;
  printf("%d\n", ans);
  std::sort(b, b + n,
            [](int x, int y) { return a[x] == a[y] ? x < y : a[x] < a[y]; });
  for (int i = 0; i < n; i++) a[b[i]] = i;
  for (int i = 0; i < n; i++) {
    tp = 0;
    for (int j = i + 1; j < n; j++)
      if (a[j] < a[i]) st[tp++] = j;
    std::sort(st, st + tp, [](int x, int y) { return a[x] > a[y]; });
    for (int j = 0; j < tp; j++) {
      printf("%d %d\n", 1 + i, 1 + st[j]);
      std::swap(a[i], a[st[j]]);
    }
  }
}
