#include <bits/stdc++.h>
using namespace std;
int n, cnt, a[1005];
struct cxf {
  int l, r, zhi;
  bool operator<(const cxf tmp) const {
    if (l != tmp.l) return l < tmp.l;
    if (zhi != tmp.zhi) return zhi > tmp.zhi;
    return r > tmp.r;
  }
} f[1000005];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++)
      if (a[i] > a[j]) {
        f[++cnt].l = i, f[cnt].r = j, f[cnt].zhi = a[j];
      }
  sort(f + 1, f + cnt + 1);
  printf("%d\n", cnt);
  for (int i = 1; i <= cnt; i++) printf("%d %d\n", f[i].l, f[i].r);
}
