#include <bits/stdc++.h>
using namespace std;
const int maxn = 300030;
inline long long read() {
  char ch = getchar();
  long long x = 0, f = 0;
  while (ch < '0' || ch > '9') f |= ch == '-', ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return f ? -x : x;
}
int n, p[maxn], id[maxn], m, a[maxn * 5], b[maxn * 5];
int tp(int x) { return x <= n / 2 ? 0 : 1; }
int main() {
  n = read();
  for (int i = (1); i <= (n); i++) id[p[i] = read()] = i;
  for (int i = (1); i <= (n); i++) {
    if (p[i] == i) continue;
    int x = i, y = id[i], t1 = tp(x), t2 = tp(y);
    if (abs(x - y) * 2 >= n) {
      m++;
      a[m] = x;
      b[m] = y;
    } else if (t1 == t2) {
      int ot = t1 ? 1 : n;
      m++;
      a[m] = x;
      b[m] = ot;
      m++;
      a[m] = y;
      b[m] = ot;
      m++;
      a[m] = x;
      b[m] = ot;
    } else {
      if (t1 > t2) swap(x, y), swap(t1, t2);
      m++;
      a[m] = x;
      b[m] = n;
      m++;
      a[m] = 1;
      b[m] = y;
      m++;
      a[m] = 1;
      b[m] = n;
      m++;
      a[m] = 1;
      b[m] = y;
      m++;
      a[m] = x;
      b[m] = n;
    }
    swap(p[x], p[y]);
    id[p[x]] = x;
    id[p[y]] = y;
  }
  printf("%d\n", m);
  for (int i = (1); i <= (m); i++) printf("%d %d\n", a[i], b[i]);
}
