#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> ar(n), h(n);
  vector<pair<int, int>> renum(n);
  for (int i = 0; i < n; i++) cin >> ar[i], renum[i] = {ar[i], i};
  iota(h.begin(), h.end(), 0);
  sort(renum.begin(), renum.end());
  for (int i = 0; i < n; i++) ar[renum[i].second] = h[i];
  vector<int> swaps[n];
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (ar[i] >= ar[j]) swaps[j].push_back(i);
    }
  }
  vector<pair<int, int>> ans;
  for (int i = n - 1; i >= 0; i--) {
    sort(swaps[i].begin(), swaps[i].end(),
         [&](int a, int b) { return ar[a] < ar[b]; });
    for (int j = 0; j < swaps[i].size(); j++)
      ans.push_back({swaps[i][j], i}), swap(ar[swaps[i][j]], ar[i]);
  }
  cout << ans.size() << "\n";
  for (auto x : ans) cout << x.first + 1 << " " << x.second + 1 << "\n";
}
