#include <bits/stdc++.h>
using namespace std;
int n, cnt = 0;
int a[1005], b[1005], c[1005], vis[1005], A[1005 * 1005], B[1005 * 1005];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    b[i] = a[i];
  }
  sort(b + 1, b + n + 1);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (!vis[j] && a[j] == b[i]) {
        c[i] = j;
        vis[j] = 1;
        break;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = n; j > c[i]; j--) {
      if (a[j] < a[c[i]]) {
        A[++cnt] = c[i], B[cnt] = j;
      }
    }
  }
  printf("%d\n", cnt);
  for (int i = 1; i <= cnt; i++) {
    printf("%d %d\n", A[i], B[i]);
  }
  return 0;
}
