#include <bits/stdc++.h>
using namespace std;
struct __timestamper {};
int main() {
  int n;
  while (scanf("%d", &n) == 1) {
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
      scanf("%d", &a[i]);
    }
    vector<pair<int, int>> ops;
    auto op = [&](int x, int y) {
      swap(a[x], a[y]);
      ops.emplace_back(min(x, y), max(x, y));
    };
    for (int i = n - 1; i >= 0; i--) {
      vector<pair<int, int>> v;
      for (int j = 0; j < i; j++) {
        if (a[j] > a[i]) {
          v.emplace_back(a[j], j);
        }
      }
      if (v.empty()) continue;
      sort(v.begin(), v.end());
      for (auto [_, pos] : v) {
        op(pos, i);
      }
      int st = v[0].second;
      for (int j = st + 1; j < i; j++) {
        if (a[j] == a[st]) {
          op(j, st);
        }
      }
      for (int j = 0; j < (int)v.size();) {
        int k = j;
        while (k < (int)v.size() && a[v[k].second] == a[v[j].second]) k++;
        for (int t = j; t < k; t++) {
          if (v[t].second > v[k - 1].second) {
            op(v[t].second, v[k - 1].second);
          }
        }
        j = k;
      }
    }
    assert(is_sorted(a.begin(), a.end()));
    printf("%zd\n", ops.size());
    for (auto [x, y] : ops) {
      printf("%d %d\n", x + 1, y + 1);
    }
  }
  return 0;
}
