#include <bits/stdc++.h>
using namespace std;
const int mod = 1e8 - 3;
struct Data {
  int a, i;
  bool operator<(const Data& d) const {
    if (a == d.a) {
      return i < d.i;
    }
    return a < d.a;
  }
};
const int N = 1e5 + 10;
int C[N];
int lowbit(int first) { return first & -first; }
void update(int first, int k) {
  while (first < N) {
    C[first] += k;
    first += lowbit(first);
  }
}
int query(int first) {
  int sum = 0;
  while (first > 0) {
    sum += C[first];
    first -= lowbit(first);
  }
  return sum;
}
int main() {
  int n;
  cin >> n;
  vector<Data> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].a;
    a[i].i = i;
  }
  for (int i = 0; i < n; i++) {
    b[i].a = b[i].i = i;
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  vector<int> c(n);
  for (int i = 0; i < n; i++) {
    c[b[i].i] = a[i].i;
  }
  vector<pair<int, int> > res;
  for (int it = 0; it < n; it++) {
    for (int i = 0; i < n - 1; i++) {
      if (c[i] > c[i + 1]) {
        res.push_back({c[i + 1], c[i]});
        swap(c[i], c[i + 1]);
      }
    }
  }
  cout << res.size() << endl;
  for (auto& p : res) {
    cout << p.first + 1 << " " << p.second + 1 << endl;
  }
}
