#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const int INF = 1000000000;
int n;
vector<int> p;
vector<int> rp;
vector<pair<int, int> > res;
void mswap(int a, int b) {
  assert(2 * abs(a - b) >= n);
  res.push_back(make_pair(a, b));
  swap(p[a], p[b]);
  rp[p[a]] = a;
  rp[p[b]] = b;
}
int main() {
  scanf("%d", &n);
  p.resize(n);
  rp.resize(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &p[i]);
    p[i]--;
    rp[p[i]] = i;
  }
  for (int i = 1; i + 1 < n; i++) {
    if (p[i] != i) {
      int x = rp[i];
      if (x >= n / 2) {
        mswap(0, x);
        x = 0;
      } else {
        mswap(n - 1, x);
        x = n - 1;
      }
      if ((i < n / 2 && x < n / 2) || (i >= n / 2 && x >= n / 2)) {
        mswap(x, n - 1 - x);
        x = n - 1 - x;
      }
      mswap(x, i);
    }
  }
  if (p[0] != 0) mswap(0, n - 1);
  assert(is_sorted(p.begin(), p.end()));
  printf("%d\n", (int)res.size());
  for (auto it : res) printf("%d %d\n", it.first + 1, it.second + 1);
  return 0;
}
