#include <bits/stdc++.h>
using namespace std;
const int N = 300100;
int n, m, p[N], inv[N], tot_ans;
class Ans {
 public:
  Ans() {}
  Ans(int _x, int _y) {
    x = _x;
    y = _y;
  }
  int x, y;
} ans[1000100];
void my_swap(int x, int y) {
  swap(inv[p[x]], inv[p[y]]);
  swap(p[x], p[y]);
  ans[++tot_ans] = Ans(x, y);
}
int main() {
  int i, j, k, pos;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &p[i]);
    inv[p[i]] = i;
  }
  tot_ans = 0;
  for (i = 1; i <= (n >> 1); i++) {
    pos = inv[i + (n >> 1)];
    if (pos <= (n >> 1)) {
      my_swap(pos, n);
      my_swap(n, i);
      my_swap(i, (n >> 1) + i);
    } else if (pos != i + (n >> 1)) {
      my_swap(pos, i);
      my_swap(i, (n >> 1) + i);
    }
    pos = inv[i];
    if (pos > (n >> 1)) {
      my_swap(pos, i);
    } else if (pos != i) {
      my_swap(pos, n);
      my_swap(n, i);
    }
  }
  printf("%d\n", tot_ans);
  for (i = 1; i <= tot_ans; i++) {
    printf("%d %d\n", ans[i].x, ans[i].y);
  }
  return 0;
}
