#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> a, b;
int n;
int main() {
  cin >> n;
  a.resize(n + 1);
  for (int i = 1; i <= n; ++i) cin >> a[i].first, a[i].second = i;
  for (int i = n; i >= 1; --i)
    for (int j = 1; j <= i - 1; ++j)
      if (a[j].first > a[j + 1].first)
        b.push_back({a[j].second, a[j + 1].second}), swap(a[j], a[j + 1]);
  cout << b.size() << '\n';
  reverse(b.begin(), b.end());
  for (auto& p : b) cout << p.first << ' ' << p.second << '\n';
  return 0;
}
