#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  std::ios_base::sync_with_stdio(false);
  long long n;
  cin >> n;
  vector<long long> a(n, 0);
  unordered_map<long long, long long> m;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    m[a[i]] = i;
  }
  vector<pair<int, int>> swaps;
  auto make_swap = [&](int l, int r) {
    swaps.emplace_back(l, r);
    m[a[l]] = r;
    m[a[r]] = l;
    swap(a[l], a[r]);
  };
  for (int i = 0; i < n; ++i) {
    int cur = m[i + 1];
    if (cur == i) {
      continue;
    }
    if (abs(cur - i) >= n / 2) {
      make_swap(i, cur);
    } else if ((i < n / 2 && cur >= n / 2) || (cur < n / 2 && i >= n / 2)) {
      int i_swap = i < n / 2 ? 0 : n - 1;
      int cur_swap = cur < n / 2 ? 0 : n - 1;
      make_swap(i, cur_swap);
      make_swap(cur, i_swap);
      make_swap(cur_swap, i_swap);
      make_swap(i, cur_swap);
      make_swap(cur, i_swap);
    } else {
      int swap = 0;
      if (cur < n / 2) {
        swap = n - 1;
      }
      make_swap(i, swap);
      make_swap(cur, swap);
      make_swap(i, swap);
    }
  }
  cout << swaps.size() << endl;
  for (int i = 0; i < swaps.size(); ++i) {
    cout << (swaps[i].first + 1) << " " << (swaps[i].second + 1) << endl;
  }
  return 0;
}
