#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 5;
int mp[maxn];
int a[maxn];
int l[maxn * 5 + 5], r[maxn * 5 + 5];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    mp[a[i]] = i;
  }
  int cnt = 0, rig = n / 2, tt;
  for (int i = 1; i <= rig; i++) {
    if (i == mp[i]) continue;
    tt = mp[i];
    if (tt > rig) {
      cnt++;
      l[cnt - 1] = 1, r[cnt - 1] = tt;
      swap(a[tt], a[1]);
      mp[a[tt]] = tt;
      mp[a[1]] = 1;
      cnt++;
      l[cnt - 1] = 1, r[cnt - 1] = n;
      swap(a[n], a[1]);
      mp[a[n]] = n;
      mp[a[1]] = 1;
      cnt++;
      l[cnt - 1] = i, r[cnt - 1] = n;
      swap(a[i], a[n]);
      mp[a[i]] = i;
      mp[a[n]] = n;
      if (i != 1 && tt != n) {
        cnt++;
        l[cnt - 1] = 1, r[cnt - 1] = tt;
        swap(a[tt], a[1]);
        mp[a[tt]] = tt;
        mp[a[1]] = 1;
      }
    } else {
      cnt++;
      l[cnt - 1] = tt, r[cnt - 1] = n;
      swap(a[n], a[tt]);
      mp[a[n]] = n;
      mp[a[tt]] = tt;
      cnt++;
      l[cnt - 1] = i, r[cnt - 1] = n;
      swap(a[i], a[n]);
      mp[a[i]] = i;
      mp[a[n]] = n;
    }
  }
  for (int i = rig + 1; i < n; i++) {
    if (i == mp[i]) continue;
    tt = mp[i];
    if (tt > rig) {
      cnt++;
      l[cnt - 1] = 1, r[cnt - 1] = tt;
      swap(a[tt], a[1]);
      mp[a[tt]] = tt;
      mp[a[1]] = 1;
      cnt++;
      l[cnt - 1] = 1, r[cnt - 1] = i;
      swap(a[1], a[i]);
      mp[a[1]] = 1;
      mp[a[i]] = i;
      cnt++;
      l[cnt - 1] = 1, r[cnt - 1] = tt;
      swap(a[tt], a[1]);
      mp[a[tt]] = tt;
      mp[a[1]] = 1;
    }
  }
  printf("%d\n", cnt);
  for (int i = 0; i < cnt; i++) {
    printf("%d %d\n", l[i], r[i]);
  }
}
