#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 9;
int a[N], pos[N];
pair<int, int> b[N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", a + i);
    b[i] = {a[i], i};
  }
  sort(b + 1, b + 1 + n);
  for (int i = 1; i <= n; ++i) {
    a[b[i].second] = i;
  }
  vector<pair<int, int> > ans;
  for (int i = 1; i <= n; ++i) {
    vector<pair<int, int> > tem;
    for (int j = i + 1; j <= n; ++j) {
      if (a[j] < a[i]) tem.push_back({a[j], j});
    }
    sort(tem.begin(), tem.end());
    reverse(tem.begin(), tem.end());
    for (auto it : tem) {
      ans.push_back({i, it.second});
    }
  }
  printf("%d\n", ans.size());
  for (auto it : ans) {
    printf("%d %d\n", it.first, it.second);
  }
}
