#include <bits/stdc++.h>
using namespace std;
int atp[300001], num[300001];
vector<pair<int, int> > ans;
void swa(int i, int j) {
  ans.push_back({i, j});
  int ati = atp[i];
  int atj = atp[j];
  atp[j] = ati;
  atp[i] = atj;
  num[ati] = j;
  num[atj] = i;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  ;
  int t;
  for (int i = 1; i < n + 1; i++) {
    cin >> t;
    num[t] = i;
    atp[i] = t;
  }
  for (int i = n; i > n / 2; i--) {
    if (num[i] == i && num[i - n / 2] == i - n / 2) continue;
    if (num[i] != i - n / 2) {
      if (num[i] != i) {
        if (num[i] > n / 2 - n + i) {
          swa(1, num[i]);
        }
        swa(num[i], i);
      }
      swa(num[i], i - n / 2);
    }
    if (num[i - n / 2] != i) {
      if (num[i - n / 2] > n / 2 - n + i) {
        swa(1, num[i - n / 2]);
      }
      swa(num[i - n / 2], i);
    }
    swa(i, i - n / 2);
  }
  int tot = ans.size();
  cout << tot << '\n';
  for (int i = 0; i < tot; i++) {
    cout << ans[i].first << " " << ans[i].second << '\n';
  }
}
