#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
const int MAXN = 300005;
int n, mid, a[MAXN], p[MAXN];
vector<pair<int, int>> List;
inline int GetInt() {
  int num = 0, bj = 1;
  char c = getchar();
  while (!isdigit(c)) bj = (bj == -1 || c == '-') ? -1 : 1, c = getchar();
  while (isdigit(c)) num = num * 10 + c - '0', c = getchar();
  return num * bj;
}
void Change(int i, int j) {
  List.push_back(make_pair(i, j));
  swap(p[a[i]], p[a[j]]);
  swap(a[i], a[j]);
}
void Work(int i, int j) {
  if (i > j) swap(i, j);
  if (2 * (j - i) >= n)
    Change(i, j);
  else if (n - i >= mid && j - 1 >= mid) {
    Change(i, n), Change(1, n);
    Change(1, j);
    Change(1, n), Change(i, n);
  } else {
    int pos = (i < mid) ? n : 1;
    Change(i, pos), Change(pos, j), Change(i, pos);
  }
}
int main() {
  n = GetInt(), mid = (n >> 1);
  for (register int i = 1; i <= n; i++) a[i] = GetInt(), p[a[i]] = i;
  for (register int i = 1; i <= n; i++) {
    if (p[i] == i) continue;
    Work(i, p[i]);
  }
  printf("%zu\n", List.size());
  for (auto ele : List) printf("%d %d\n", ele.first, ele.second);
  return 0;
}
