#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  for (int i = 0; i < n; ++i) {
    auto &[x, id] = a[i];
    cin >> x;
    id = i;
  }
  vector<pair<int, int>> ans;
  for (int _ = 0; _ < n; ++_) {
    for (int i = 0; i + 1 < n; ++i) {
      if (a[i].first > a[i + 1].first) {
        ans.emplace_back(a[i].second, a[i + 1].second);
        swap(a[i], a[i + 1]);
      }
    }
  }
  reverse(ans.begin(), ans.end());
  cout << ans.size() << '\n';
  for (const auto [u, v] : ans) cout << u + 1 << " " << v + 1 << '\n';
  return 0;
}
