#include <bits/stdc++.h>
using namespace std;
long long poww(long long a, long long b, long long md) {
  return (!b ? 1
             : (b & 1 ? a * poww(a * a % md, b / 2, md) % md
                      : poww(a * a % md, b / 2, md) % md));
}
const long long MAXN = 1e6 + 10;
const long long INF = 8e18;
const long long MOD = 1e9 + 7;
long long A[MAXN], n;
vector<long long> inv[MAXN];
vector<pair<long long, long long> > ans;
bool cmp(long long i, long long j) {
  if (A[i] < A[j]) return true;
  if (A[i] > A[j]) return false;
  return i < j;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> A[i];
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      if (A[i] > A[j]) inv[j].push_back(i);
  for (int i = n - 1; i >= 0; i--) {
    sort((inv[i]).begin(), (inv[i]).end(), cmp);
    for (long long e : inv[i]) {
      ans.push_back({e, i});
    }
  }
  cout << ans.size() << '\n';
  for (pair<long long, long long> e : ans)
    cout << e.first + 1 << ' ' << e.second + 1 << '\n';
  return 0;
}
