#include <bits/stdc++.h>
using namespace std;
void faster() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
const long long INF = 1e18;
const long long MAXN = 1 << 20;
const long long MOD = 1e9 + 7;
const int dx[8] = {-1, 0, 1, 0, 1, 1, -1, -1};
const int dy[8] = {0, -1, 0, 1, 1, -1, 1, -1};
long long n, a[MAXN], b[MAXN];
vector<pair<long long, long long>> g[MAXN], ans;
void solve() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b, b + n);
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (a[i] > a[j]) {
        g[j].push_back({a[i], i});
      }
    }
  }
  for (int i = n - 1; i >= 0; --i) {
    sort(g[i].begin(), g[i].end());
    for (auto &&[x, j] : g[i]) {
      swap(a[i], a[j]);
      ans.push_back({i, j});
    }
  }
  assert(is_sorted(a, a + n));
  cout << ans.size() << '\n';
  for (auto &&[x, y] : ans) {
    cout << y + 1 << ' ' << x + 1 << '\n';
  }
}
int main() {
  faster();
  int T = 1;
  while (T--) {
    solve();
  }
  return 0;
}
