#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 5;
const int ha = 998244353;
struct P {
  int t, v;
  P(int a = 0, int b = 0) : t(a), v(b) {}
};
vector<P> V[N];
vector<P> ans;
bool operator<(const P &A, const P &B) {
  return (A.v == B.v) ? (A.t < B.t) : A.v < B.v;
}
int A[N], n;
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> A[i];
  }
  for (int i = 1; i <= n; ++i)
    for (int j = i + 1; j <= n; ++j) {
      if (A[j] < A[i]) V[j].push_back(P(i, A[i]));
    }
  for (int i = n; i >= 1; --i) {
    sort(V[i].begin(), V[i].end());
    for (auto &j : V[i]) {
      ans.push_back(P(j.t, i));
    }
  }
  printf("%u\n", ans.size());
  for (auto &it : ans) {
    printf("%d %d\n", it.t, it.v);
  }
  return 0;
}
