#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using cd = complex<double>;
int main() {
  int n;
  cin >> n;
  int ar[n], pos[n + 1];
  vector<pair<int, int>> vp;
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
    vp.push_back(make_pair(ar[i], i));
  }
  sort(vp.begin(), vp.end());
  for (int i = 0; i < n; i++) {
    ar[vp[i].second] = i + 1;
    pos[i + 1] = vp[i].second + 1;
  }
  vp.clear();
  for (int i = n - 1; i >= 0; i--) {
    for (int j = ar[i] + 1; j <= i + 1; j++) {
      int u = pos[j], v = i + 1;
      vp.push_back(make_pair(u, v));
      swap(pos[ar[u - 1]], pos[ar[i]]);
      swap(ar[u - 1], ar[i]);
    }
  }
  cout << vp.size() << '\n';
  for (auto x : vp) {
    cout << x.first << " " << x.second << "\n";
  }
}
