#include <bits/stdc++.h>
using namespace std;
int a[3000005], b[3000005], c[3000005], d[3000005], n, t;
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i], b[i] = i;
  for (int i = n; i >= 1; --i)
    for (int j = 1; j <= i - 1; ++j)
      if (a[j] > a[j + 1])
        c[++t] = b[j], d[t] = b[j + 1], swap(a[j], a[j + 1]),
        swap(b[j], b[j + 1]);
  cout << t << '\n';
  for (int i = t; i >= 1; --i) cout << c[i] << ' ' << d[i] << '\n';
}
