#include <bits/stdc++.h>
using namespace std;
queue<int> q;
const int oo = 1e9 + 10;
const int N = 3000 + 10;
int n, a[N];
int find_max(int l) {
  int mx = -oo, ind = 0;
  for (int i = 0; i <= l; i++) {
    if (a[i] >= mx) {
      mx = a[i];
      ind = i;
    }
  }
  return ind;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  int cnt = 0;
  for (int k = n - 1; k > 0; k--) {
    int y = find_max(k);
    if (y != k) {
      q.push(k);
      q.push(y);
      swap(a[k], a[y]);
      cnt++;
    }
  }
  cout << cnt << endl;
  while (!q.empty()) {
    cout << q.front() << endl;
    q.pop();
  }
  return 0;
}
