#include <bits/stdc++.h>
using namespace std;
const long long MOD = (long long)1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;
long long fac[1] = {1}, inv[1] = {1};
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long mp(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = ret * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return ret;
}
long long cmb(long long r, long long c) {
  return fac[r] * inv[c] % MOD * inv[r - c] % MOD;
}
priority_queue<int, vector<int>, greater<int>> pq;
vector<int> v;
int vec[1000];
int mat[1000][1000];
int main() {
  int n;
  scanf("%d", &n);
  vector<pair<int, int>> ans;
  for (int i = 0; i < n; i++) {
    scanf("%d", &vec[i]);
    for (int j = 0; j < i; j++)
      if (vec[j] > vec[i]) mat[i][j] = 1;
  }
  for (int i = n - 1; i >= 0; i--) {
    vector<int> ord;
    for (int j = 0; j < i; j++)
      if (mat[i][j]) ord.push_back(j);
    sort((ord).begin(), (ord).end(), [](int a, int b) {
      if (vec[a] == vec[b]) return a < b;
      return vec[a] < vec[b];
    });
    for (int j : ord) ans.push_back({j, i});
  }
  printf("%d\n", (int)(ans).size());
  for (pair<int, int> i : ans) printf("%d %d\n", i.first + 1, i.second + 1);
}
