#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
inline int safe_mul(const int x, const int y)
    __attribute__((warn_unused_result));
int const maxn = 300005;
int p[maxn];
int pos[maxn];
vector<pair<int, int>> res;
inline void SW(const int x, const int y) {
  res.emplace_back(x, y);
  swap(p[x], p[y]);
  pos[p[x]] = x;
  pos[p[y]] = y;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> p[i];
    pos[p[i]] = i;
  }
  int const h = n / 2;
  for (int i = 2; i < n; ++i) {
    if (p[i] != i) {
      int x = pos[i];
      int tmp = x > h ? 1 : n;
      SW(tmp, x);
      if (abs(tmp - i) >= h)
        SW(tmp, i);
      else {
        int tmp2 = n + 1 - tmp;
        SW(tmp, tmp2);
        SW(i, tmp2);
      }
      SW(tmp, x);
    }
  }
  for (int cnt = 0; cnt < 3; ++cnt)
    for (int i = 1; i <= n; ++i)
      if (p[i] != i && (p[i] == 1 || p[i] == n)) {
        res.emplace_back(i, p[i]);
        swap(p[i], p[p[i]]);
      }
  cout << res.size() << endl;
  for (const auto& pa : res) cout << pa.first << ' ' << pa.second << '\n';
}
