#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long su = 0, f = 1;
  char c = getchar();
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') f = -1;
  for (; c >= '0' && c <= '9'; c = getchar()) su = su * 10 + c - '0';
  return su * f;
}
inline void wr(long long x) {
  if (x < 0)
    putchar('-'), wr(-x);
  else {
    if (x >= 10) wr(x / 10);
    putchar(x % 10 + '0');
  }
}
inline void wri(long long x) {
  wr(x);
  putchar(' ');
}
inline void wrn(long long x) {
  wr(x);
  putchar('\n');
}
inline void wrn(long long x, long long y) {
  wri(x);
  wrn(y);
}
inline void wrn(long long x, long long y, long long z) {
  wri(x);
  wrn(y, z);
}
int n, m, a[6000055], p[6000055], tot;
pair<int, int> z[6000055];
signed main() {
  n = read();
  for (int i = int(1); i <= int(n); i++) a[i] = read(), p[i] = i;
  for (int i = int(1); i <= int(n); i++) {
    for (int j = int(1); j < int(n); j++) {
      if (a[j] > a[j + 1]) {
        z[++tot] = make_pair(p[j], p[j + 1]);
        swap(a[j], a[j + 1]);
        swap(p[j], p[j + 1]);
      }
    }
  }
  wrn(tot);
  for (int i = int(tot); i >= int(1); i--) wrn(z[i].first, z[i].second);
  return 0;
}
