#include <bits/stdc++.h>
using namespace std;
const int Maxn = 3e5 + 5;
struct node {
  int a, b;
};
node ans[5 * Maxn];
int p[Maxn], f[Maxn];
int main() {
  srand((unsigned)time(NULL));
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &p[i]);
    f[p[i]] = i;
  }
  int tot = 0;
  for (int i = n / 2; i > 1; i--) {
    if (f[i] <= n / 2 && f[i] != i) {
      int temp;
      tot++;
      ans[tot].a = f[i];
      ans[tot].b = n;
      temp = p[f[i]];
      p[f[i]] = p[n];
      p[n] = temp;
      f[p[f[i]]] = f[i];
      f[p[n]] = n;
      temp = p[n];
      p[n] = p[i];
      p[i] = temp;
      f[p[n]] = n;
      f[p[i]] = i;
      tot++;
      ans[tot].a = i;
      ans[tot].b = n;
    }
    if (f[i] > n / 2) {
      int temp;
      tot++;
      ans[tot].a = f[i];
      ans[tot].b = 1;
      temp = p[f[i]];
      p[f[i]] = p[1];
      p[1] = temp;
      f[p[f[i]]] = f[i];
      f[p[1]] = 1;
      temp = p[n];
      p[n] = p[1];
      p[1] = temp;
      f[p[n]] = n;
      f[p[1]] = 1;
      tot++;
      ans[tot].a = 1;
      ans[tot].b = n;
      temp = p[n];
      p[n] = p[i];
      p[i] = temp;
      f[p[n]] = n;
      f[p[i]] = i;
      tot++;
      ans[tot].a = n;
      ans[tot].b = i;
    }
    if (f[n - i + 1] > n / 2 && f[n - i + 1] != n - i + 1) {
      int temp;
      tot++;
      ans[tot].a = f[n - i + 1];
      ans[tot].b = 1;
      temp = p[f[n - i + 1]];
      p[f[n - i + 1]] = p[1];
      p[1] = temp;
      f[p[f[n - i + 1]]] = f[n - i + 1];
      f[p[1]] = 1;
      temp = p[1];
      p[1] = p[n - i + 1];
      p[n - i + 1] = temp;
      f[p[1]] = 1;
      f[p[n - i + 1]] = n - i + 1;
      tot++;
      ans[tot].a = n - i + 1;
      ans[tot].b = 1;
    }
    if (f[n - i + 1] <= n / 2) {
      int temp;
      tot++;
      ans[tot].a = f[n - i + 1];
      ans[tot].b = n;
      temp = p[f[n - i + 1]];
      p[f[n - i + 1]] = p[n];
      p[n] = temp;
      f[p[f[n - i + 1]]] = f[n - i + 1];
      f[p[n]] = n;
      temp = p[n];
      p[n] = p[1];
      p[1] = temp;
      f[p[n]] = n;
      f[p[1]] = 1;
      tot++;
      ans[tot].a = 1;
      ans[tot].b = n;
      temp = p[1];
      p[1] = p[n - i + 1];
      p[n - i + 1] = temp;
      f[p[1]] = 1;
      f[p[n - i + 1]] = n - i + 1;
      tot++;
      ans[tot].a = 1;
      ans[tot].b = n - i + 1;
    }
  }
  if (p[1] != 1) {
    int temp;
    temp = p[1];
    p[1] = p[n];
    p[n] = temp;
    tot++;
    ans[tot].a = 1;
    ans[tot].b = n;
  }
  printf("%d\n", tot);
  for (int i = 1; i <= tot; i++) printf("%d %d\n", ans[i].a, ans[i].b);
  return 0;
}
