#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<int> A(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> A[i];
  }
  vector<pair<int, int>> ans;
  vector<int> B = A;
  vector<vector<int>> need(n + 1, vector<int>(n + 1));
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      need[i][j] = A[i] > A[j];
    }
  }
  auto do_swap = [&](int u, int v) {
    swap(B[u], B[v]);
    ans.push_back(pair<int, int>(u, v));
    assert(need[u][v]);
    need[u][v] = 0;
  };
  for (int i = 1; i <= n; i++) {
    vector<pair<int, int>> tgt;
    for (int j = i + 1; j <= n; j++) {
      if (need[i][j]) {
        assert(B[i] > B[j]);
        tgt.push_back(pair<int, int>(B[j], j));
      } else {
        assert(B[i] <= B[j]);
      }
    }
    sort((tgt).begin(), (tgt).end(), greater<pair<int, int>>());
    for (pair<int, int> p : tgt) {
      do_swap(i, p.second);
    }
    if (!tgt.empty()) {
      int l = 0;
      while (l < tgt.size()) {
        int r = l + 1;
        while (r < tgt.size() && B[tgt[r].second] == B[tgt[l].second]) {
          r++;
        }
        for (int j = l; j < r - 1; j++) {
          int u = tgt[r - 1].second, v = tgt[j].second;
          if (u > v) swap(u, v);
          if (need[u][v] && B[u] == B[v]) {
            do_swap(u, v);
          }
        }
        l = r;
      }
      for (int j = i + 1; j <= n; j++) {
        int u = tgt[0].second, v = j;
        if (u > v) swap(u, v);
        if (need[u][v] && B[u] == B[v]) {
          do_swap(u, v);
        }
      }
    }
  }
  cout << ans.size() << '\n';
  for (pair<int, int> p : ans) {
    cout << p.first << ' ' << p.second << '\n';
    assert(A[p.first] > A[p.second]);
  }
  for (int i = 1; i < n; i++) {
    assert(B[i] <= B[i + 1]);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int tc = 1;
  for (int i = 1; i <= tc; i++) {
    solve();
  }
  return 0;
}
