#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 5;
int a[1005];
vector<int> v[1005];
pair<int, int> p[1005];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
    p[i] = make_pair(a[i], i);
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (a[j] < a[i]) {
        v[i].push_back(j);
        cnt++;
      }
    }
  }
  sort(p, p + n);
  printf("%d\n", cnt);
  for (int i = 0; i < n; i++) {
    sort(v[p[i].second].begin(), v[p[i].second].end());
    for (int j = v[p[i].second].size() - 1; j >= 0; j--) {
      printf("%d %d\n", p[i].second + 1, v[p[i].second][j] + 1);
    }
  }
  return 0;
}
