#include <bits/stdc++.h>
using namespace std;
void gao(const int N, const vector<int> &a) {
  vector<vector<int>> invs(N);
  vector<int> idx_inv;
  int total_inv = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      if (a[i] > a[j]) {
        invs[i].push_back(j);
      }
    }
    if (invs[i].size() > 0) {
      idx_inv.push_back(i);
      total_inv += invs[i].size();
      reverse(invs[i].begin(), invs[i].end());
    }
  }
  sort(idx_inv.begin(), idx_inv.end(),
       [&a](int i, int j) { return a[i] != a[j] ? a[i] < a[j] : i < j; });
  cout << total_inv << endl;
  for (const auto &i : idx_inv) {
    for (const auto &j : invs[i]) {
      cout << i + 1 << " " << j + 1 << endl;
    }
  }
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  gao(n, a);
  return 0;
}
