#include <bits/stdc++.h>
using namespace std;
const long double pi = 2 * acos(0.0);
template <class T>
bool umin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool umax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class TT>
bool pal(T a, TT n) {
  int k = 0;
  for (int i = 0; i <= n / 2; i++) {
    if (a[i] != a[n - i - 1]) {
      k = 1;
      break;
    }
  }
  return k ? 0 : 1;
}
long long a[222222];
pair<long long, long long> p[222222];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    p[i] = make_pair(a[i], i);
  }
  sort(p + 1, p + n + 1);
  int id = 0;
  for (int i = 1; i <= n; i++) a[p[i].second] = ++id;
  vector<pair<int, int> > ans;
  for (int i = n; i; i--) {
    vector<pair<int, int> > v;
    for (int j = 1; j < i; j++) {
      if (a[j] > a[i]) {
        v.push_back(make_pair(a[j], j));
      }
    }
    sort(v.begin(), v.end());
    for (auto it : v)
      ans.push_back(make_pair(it.second, i)), swap(a[it.second], a[i]);
  }
  cout << ans.size() << '\n';
  for (auto it : ans) cout << it.first << ' ' << it.second << '\n';
  getchar();
  getchar();
  return 0;
}
