#include <bits/stdc++.h>
using namespace std;
int n = 0, a[600010] = {}, m = 0, ans[2][1500010] = {}, psi[600010] = {};
int vis(int x) { return x <= n / 2 ? n : 1; }
void sol(int x, int y) { ans[0][++m] = x, ans[1][m] = y; }
void swo(int x, int y) {
  int gx = vis(x), gy = vis(y);
  if (abs(x - y) >= n / 2) {
    sol(x, y);
  } else {
    if (gx != gy) {
      sol(x, gx), sol(y, gy), sol(1, n), sol(x, gx), sol(y, gy);
    } else {
      sol(x, gx), sol(y, gx), sol(x, gx);
    }
  }
  std::swap(psi[a[x]], psi[a[y]]);
  std::swap(a[x], a[y]);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    psi[a[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    if (psi[i] != i) swo(psi[i], i);
  }
  printf("%d\n", m);
  for (int i = 1; i <= m; i++) printf("%d %d\n", ans[0][i], ans[1][i]);
  return 0;
}
