#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> ar(n);
  for (auto &i : ar) cin >> i;
  vector<vector<int> > pos(n);
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      if (ar[i] > ar[j]) pos[j].push_back(i);
  vector<pair<int, int> > ans;
  for (int i = n - 1; i >= 0; i--) {
    sort(pos[i].begin(), pos[i].end(), [&](const int &a, const int &b) {
      return (ar[a] == ar[b]) ? a < b : ar[a] < ar[b];
    });
    for (auto j : pos[i]) ans.push_back(make_pair(j + 1, i + 1));
  }
  cout << ans.size() << '\n';
  for (auto [i, j] : ans) cout << i << ' ' << j << '\n';
}
