#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T lowbit(T x) {
  return x & (-x);
}
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <class T>
inline T Pow(T a, T b, T p) {
  T ret = 1;
  a %= p;
  for (; b; b >>= 1, a = a * a % p)
    if (b & 1) (ret *= a) %= p;
  return ret;
}
template <class T>
inline void read(T &ret) {
  T x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  ret = x * f;
}
const int N = 3E5 + 10;
int n, p[N], loc[N];
pair<int, int> opt[N * 5];
int top = 0;
void Swap(int x, int y) {
  opt[++top] = make_pair(x, y);
  loc[p[x]] = y;
  loc[p[y]] = x;
  swap(p[x], p[y]);
}
int main() {
  read(n);
  for (int i = (1); i <= (n); i++) read(p[i]), loc[p[i]] = i;
  int hlf = n / 2;
  for (int i = (1); i <= (hlf); i++) {
    if (i == loc[i]) continue;
    if ((loc[i] - i) >= hlf) {
      Swap(loc[i], i);
      continue;
    }
    int x = loc[i];
    if (x <= hlf) {
      Swap(x, n);
      Swap(n, i);
      Swap(n, x);
    } else {
      Swap(x, 1);
      Swap(1, n);
      Swap(n, i);
      Swap(1, n);
      Swap(1, x);
    }
  }
  for (int i = (hlf + 1); i <= (n); i++) {
    if (i == loc[i]) continue;
    if ((loc[i] - i) >= hlf) {
      Swap(loc[i], i);
      continue;
    }
    int x = loc[i];
    if (x > hlf) {
      Swap(x, 1);
      Swap(1, i);
      Swap(1, x);
    } else {
      Swap(x, n);
      Swap(1, n);
      Swap(1, i);
      Swap(1, n);
      Swap(n, x);
    }
  }
  printf("%d\n", top);
  for (int i = (1); i <= (top); i++)
    printf("%d %d\n", opt[i].first, opt[i].second);
}
