#include <bits/stdc++.h>
using namespace std;
int a[300005], p[300005];
int aa[300005], pp[300005];
void do_swap(int i, int j) {
  int v1 = a[i];
  int v2 = a[j];
  swap(a[i], a[j]);
  swap(p[v1], p[v2]);
}
void do_swap2(int i, int j) {
  int v1 = aa[i];
  int v2 = aa[j];
  swap(aa[i], aa[j]);
  swap(pp[v1], pp[v2]);
}
int main() {
  int n;
  cin >> n;
  int h = n / 2;
  vector<pair<int, int> > ans;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    tmp--;
    a[i] = tmp;
    p[tmp] = i;
    aa[i] = tmp;
    pp[tmp] = i;
  }
  for (int i = 0; i < n; i++) {
    while (a[i] != i) {
      int v1 = i;
      int v2 = a[i];
      if (abs(v2 - v1) >= h) {
        ans.emplace_back(make_pair(v1, v2));
        do_swap(v1, v2);
      } else if (max(v1, v2) < h) {
        ans.emplace_back(make_pair(v1, n - 1));
        ans.emplace_back(make_pair(v2, n - 1));
        ans.emplace_back(make_pair(v1, n - 1));
        do_swap(v1, n - 1);
        do_swap(v2, n - 1);
        do_swap(v1, n - 1);
      } else if (min(v1, v2) >= h) {
        ans.emplace_back(make_pair(v1, 0));
        ans.emplace_back(make_pair(v2, 0));
        ans.emplace_back(make_pair(v1, 0));
        do_swap(v1, 0);
        do_swap(v2, 0);
        do_swap(v1, 0);
      } else {
        ans.emplace_back(make_pair(v1, n - 1));
        ans.emplace_back(make_pair(0, n - 1));
        ans.emplace_back(make_pair(0, v2));
        ans.emplace_back(make_pair(0, n - 1));
        ans.emplace_back(make_pair(v1, n - 1));
        do_swap(v1, n - 1);
        do_swap(0, n - 1);
        do_swap(0, v2);
        do_swap(0, n - 1);
        do_swap(v1, n - 1);
      }
      do_swap2(v1, v2);
    }
  }
  cout << ans.size() << '\n';
  for (auto v : ans) {
    cout << (v.first + 1) << ' ' << (v.second + 1) << '\n';
  }
}
