#include <bits/stdc++.h>
using namespace std;
const int N = 1500003;
int n, p[N], x[N], y[N], m;
inline void change(int a, int b) {
  if (a > b) swap(a, b);
  if (b - a >= (n >> 1)) {
    x[++m] = a;
    y[m] = b;
    return;
  }
  if (b <= (n >> 1)) {
    x[++m] = a;
    y[m] = n;
    x[++m] = b;
    y[m] = n;
    x[++m] = a;
    y[m] = n;
    return;
  }
  if (a > (n >> 1)) {
    x[++m] = 1;
    y[m] = b;
    x[++m] = 1;
    y[m] = a;
    x[++m] = 1;
    y[m] = b;
    return;
  }
  x[++m] = 1;
  y[m] = b;
  x[++m] = a;
  y[m] = n;
  x[++m] = 1;
  y[m] = n;
  x[++m] = 1;
  y[m] = b;
  x[++m] = a;
  y[m] = n;
}
int main() {
  scanf("%d", &n);
  for (register int i = 1; i <= n; i++) scanf("%d", p + i);
  for (register int i = 1; i <= n; i++) {
    while (p[i] != i) {
      change(i, p[i]);
      int t = p[i];
      swap(p[i], p[t]);
    }
  }
  printf("%d\n", m);
  for (register int i = 1; i <= m; i++) printf("%d %d\n", x[i], y[i]);
}
