#include <bits/stdc++.h>
const int N = 1005;
int n, a[N], p[N];
std::pair<int, int> pr[N], ans[N * N];
int m;
int main(void) {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    scanf("%d", a + i), pr[i] = std::make_pair(a[i], i);
  std::sort(pr + 1, pr + 1 + n);
  for (int i = 1; i <= n; ++i) p[i] = pr[i].second;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j < n; ++j)
      if (p[j] > p[j + 1])
        ans[++m] = std::make_pair(p[j + 1], p[j]), std::swap(p[j], p[j + 1]);
  printf("%d\n", m);
  for (int i = 1; i <= m; ++i) printf("%d %d\n", ans[i].first, ans[i].second);
  return 0;
}
