#include <bits/stdc++.h>
using namespace std;
int a[300005], pos[300005];
vector<pair<int, int> > ans;
int read() {
  char c = getchar();
  int x = 0, f = 1;
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
void move(int x, int y) {
  ans.push_back(make_pair(x, y));
  swap(pos[a[x]], pos[a[y]]);
  swap(a[x], a[y]);
}
int main() {
  int n = read();
  for (int i = 1; i <= n; i++) a[i] = read(), pos[a[i]] = i;
  for (int i = 2; i < n / 2; i++) {
    if (pos[i] == i + n / 2 || pos[i + n / 2] == i) move(i, i + n / 2);
    if (pos[i] == i && pos[i + n / 2] == i + n / 2) continue;
    if (pos[i] == n) move(i, n);
    if (pos[i] == 1) move(1, n), move(i, n);
    if (pos[i + n / 2] == 1) move(1, i + n / 2);
    if (pos[i + n / 2] == n) move(1, n), move(1, i + n / 2);
    if (pos[i] == i) {
      if (pos[i + n / 2] <= n / 2) move(pos[i + n / 2], n);
      move(pos[i + n / 2], 1);
      move(pos[i + n / 2], i + n / 2);
    } else if (pos[i + n / 2] == i + n / 2) {
      if (pos[i] > n / 2) move(pos[i], 1);
      move(pos[i], n);
      move(pos[i], i);
    } else if (pos[i] <= n / 2 && pos[i + n / 2] <= n / 2) {
      move(pos[i], n);
      move(pos[i], i);
      move(pos[i + n / 2], n);
      move(pos[i + n / 2], 1);
      move(pos[i + n / 2], i + n / 2);
    } else if (pos[i] > n / 2 && pos[i + n / 2] > n / 2) {
      move(pos[i + n / 2], 1);
      move(pos[i + n / 2], i + n / 2);
      move(pos[i], 1);
      move(pos[i], n);
      move(pos[i], i);
    } else if (pos[i] <= n / 2 && pos[i + n / 2] > n / 2) {
      move(pos[i], n);
      move(pos[i], i);
      move(pos[i + n / 2], 1);
      move(pos[i + n / 2], i + n / 2);
    } else if (pos[i] > n / 2 && pos[i + n / 2] <= n / 2) {
      move(pos[i], 1);
      move(pos[i], i + n / 2);
      move(pos[i + n / 2], n);
      move(pos[i + n / 2], i);
      move(i, i + n / 2);
    }
  }
  if (pos[n / 2] == 1) {
    move(1, n);
    move(n / 2, n);
  } else if (pos[n / 2] == n / 2 + 1) {
    move(1, n / 2 + 1);
    move(1, n);
    move(n / 2, n);
  } else if (pos[n / 2] == n)
    move(n / 2, n);
  if (pos[n / 2 + 1] == n) {
    move(1, n);
    move(1, n / 2 + 1);
  } else if (pos[n / 2 + 1] == n / 2) {
    move(n / 2, n);
    move(1, n);
    move(1, n / 2 + 1);
  } else if (pos[n / 2 + 1] == 1)
    move(1, n / 2 + 1);
  if (a[1] != 1) move(1, n);
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); i++) {
    int x = ans[i].first, y = ans[i].second;
    if (x > y) swap(x, y);
    printf("%d %d\n", x, y);
  }
  return 0;
}
