#include <bits/stdc++.h>
using namespace std;
int cmp(const void* p, const void* q) {
  int *x = (int*)p, *y = (int*)q;
  return *x - *y;
}
int cmp_ll(const void* p, const void* q) {
  long long *x = (long long*)p, *y = (long long*)q;
  if (*x < *y)
    return -1;
  else if (*x > *y)
    return 1;
  else
    return 0;
}
long long extended_gcd(long long n, long long m, long long& x, long long& y) {
  if (m == 0) {
    x = 1;
    y = 0;
    return n;
  } else {
    long long r = extended_gcd(m, n % m, y, x);
    y -= x * (n / m);
    return r;
  }
}
bool comp(vector<int>& x, vector<int>& y) {
  return x[0] < y[0] || x[0] == y[0] && x[1] < y[1];
}
int main() {
  int T = 1, n;
  while (T-- > 0) {
    scanf("%d", &n);
    int a[n], inv = 0;
    vector<vector<int> > b;
    for (int i = 0; i < n; i++) {
      scanf("%d", &a[i]);
      vector<int> c;
      c.push_back(a[i]);
      c.push_back(i);
      b.push_back(c);
    }
    sort(begin(b), end(b), comp);
    int index[n];
    for (int i = 0; i < n; i++) index[b[i][1]] = i;
    vector<vector<int> > l(n);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < i; j++)
        if (index[j] > index[i]) {
          inv++;
          l[i].push_back(j);
        }
    }
    printf("%d\n", inv);
    vector<vector<int> > ll;
    for (int i = n - 1; i >= 0; i--) {
      ll.clear();
      for (auto x : l[i]) {
        vector<int> c;
        c.push_back(index[x]);
        c.push_back(x);
        ll.push_back(c);
      }
      if (!ll.empty()) {
        sort(begin(ll), end(ll), comp);
        for (const auto& p : ll) {
          printf("%d %d\n", p[1] + 1, i + 1);
          int tmp = index[i];
          index[i] = p[0];
          index[p[1]] = tmp;
        }
      }
    }
  }
  return 0;
}
