#include <bits/stdc++.h>
const int N = 1010;
const int mod = 1000000007;
const int inf = 0x3f3f3f3f;
int n;
int a[N];
std::vector<int> b[N];
std::vector<std::pair<int, int>> ans;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    for (int j = 1; j < i; ++j) {
      if (a[j] > a[i]) b[i].push_back(j);
    }
  }
  for (int i = 1; i <= n; ++i) {
    std::sort(b[i].begin(), b[i].end(), [](const int& x, const int& y) {
      return std::pair<int, int>(a[x], x) < std::pair<int, int>(a[y], y);
    });
  }
  for (int i = n; i >= 1; --i) {
    for (size_t j = 0; j < b[i].size(); ++j) {
      ans.push_back({b[i][j], i});
      std::swap(a[i], a[b[i][j]]);
    }
  }
  printf("%d\n", (int)ans.size());
  for (size_t i = 0; i < ans.size(); ++i)
    printf("%d %d\n", ans[i].first, ans[i].second);
  return 0;
}
