#include <bits/stdc++.h>
using namespace std;
int n, a[1005], b[1005], x[1000005], y[1000005], k;
pair<int, int> p[1005];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i), p[i] = make_pair(a[i], i);
  sort(p + 1, p + n + 1);
  for (int i = 1; i <= n; ++i) a[p[i].second] = i;
  for (int i = 1; i <= n; ++i) b[a[i]] = i;
  for (int i = 1; i <= n; ++i) {
    for (int j = n; j > b[i]; --j) {
      if (a[j] < i) {
        ++k;
        x[k] = b[i], y[k] = j;
      }
    }
  }
  printf("%d\n", k);
  for (int i = 1; i <= k; ++i) printf("%d %d\n", x[i], y[i]);
  return 0;
}
