#include <bits/stdc++.h>
using namespace std;
const int N = 1111;
int a[N];
vector<int> pairs[N];
vector<pair<int, int> > ans;
int n;
void update(int i, int j) {
  ans.push_back({i, j});
  swap(a[i], a[j]);
}
void toperm() {
  map<int, vector<int> > poss;
  for (int i = (1); i <= (n); i++) {
    poss[a[i]].push_back(i);
  }
  int cur = 1;
  for (auto p : poss) {
    for (int i = (0); i <= ((int)(p.second).size() - 1); i++) {
      a[p.second[i]] = cur;
      cur++;
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  toperm();
  for (int i = (1); i <= (n - 1); i++) {
    for (int j = (i + 1); j <= (n); j++) {
      if (a[i] > a[j]) {
        pairs[j].push_back(i);
      }
    }
  }
  for (int r = (n); r >= (1); r--) {
    vector<pair<int, int> > le;
    for (auto l : pairs[r]) {
      le.push_back({a[l], l});
    }
    sort(le.begin(), le.end());
    for (auto p : le) {
      update(p.second, r);
    }
  }
  cout << (int)(ans).size() << "\n";
  for (auto p : ans) {
    cout << p.first << " " << p.second << "\n";
  }
  return 0;
}
