#include <bits/stdc++.h>
namespace ztd {
using namespace std;
template <typename T>
inline T read(T &t) {
  t = 0;
  short f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -f;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') t = t * 10 + ch - '0', ch = getchar();
  t *= f;
  return t;
}
}  // namespace ztd
using namespace ztd;
const int maxn = 1007;
int n;
struct node {
  int x, id;
  bool operator<(const node &rhs) const {
    if (x != rhs.x) return x < rhs.x;
    return id < rhs.id;
  }
  bool operator==(const node &rhs) const { return x == rhs.x && id == rhs.id; }
} a[maxn], b[maxn];
int c[maxn];
int ans, ax[maxn * maxn], ay[maxn * maxn];
signed main() {
  read(n);
  for (int i = 1; i <= n; ++i) {
    read(a[i].x);
    a[i].id = 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 (a[i] == b[j]) {
        c[j] = i;
        break;
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 2; j <= n; ++j) {
      if (c[j] < c[j - 1]) {
        ax[++ans] = c[j];
        ay[ans] = c[j - 1];
        swap(c[j], c[j - 1]);
      }
    }
  }
  cout << ans << '\n';
  for (int i = 1; i <= ans; ++i)
    cout << min(ax[i], ay[i]) << ' ' << max(ax[i], ay[i]) << '\n';
  return 0;
}
