#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
const int N = 3e5 + 5;
int n, P[N], M[N];
vector<PII> Ans;
void mswap(int i, int j) {
  Ans.emplace_back(i, j);
  M[P[i]] = j, M[P[j]] = i;
  swap(P[i], P[j]);
}
bool left(int i) { return abs(i - 1) <= abs(n - i); }
void solve(int i) {
  int j = P[i];
  if (i == j) return;
  if (left(i) && left(j)) {
    mswap(i, n);
    mswap(j, n);
    mswap(i, n);
  } else if (left(i) && !left(j)) {
    mswap(i, n);
    mswap(1, j);
    mswap(1, n);
    mswap(1, j);
    mswap(i, n);
  } else if (!left(i) && left(j)) {
    mswap(1, i);
    mswap(j, n);
    mswap(1, n);
    mswap(j, n);
    mswap(1, i);
  } else if (!left(i) && !left(j)) {
    mswap(1, i);
    mswap(1, j);
    mswap(1, i);
  }
}
int main() {
  cin >> n;
  for (int i = (1); i <= (n); ++i) scanf("%d", &P[i]);
  for (int i = (1); i <= (n); ++i) M[P[i]] = i;
  for (int i = (1); i <= (n); ++i) solve(M[i]);
  cout << Ans.size() << endl;
  for (auto [x, y] : Ans) printf("%d %d\n", x, y);
}
