#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
const int mod = 998244353;
const int maxn = 3e5 + 50;
const int inf = 1e9;
const long long onf = 1e18;
using namespace std;
int a[maxn], pos[maxn];
vector<pair<int, int>> ans;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    pos[a[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] != i) {
      if (pos[i] - i >= n / 2) {
        ans.push_back(make_pair(i, pos[i]));
      } else if (pos[i] - 1 >= n / 2 && n - i >= n / 2) {
        ans.push_back(make_pair(1, pos[i]));
        ans.push_back(make_pair(i, n));
        ans.push_back(make_pair(1, n));
        ans.push_back(make_pair(1, pos[i]));
        ans.push_back(make_pair(i, n));
      } else if (i - 1 >= n / 2 && pos[i] - 1 >= n / 2) {
        ans.push_back(make_pair(1, i));
        ans.push_back(make_pair(1, pos[i]));
        ans.push_back(make_pair(1, i));
      } else {
        ans.push_back(make_pair(i, n));
        ans.push_back(make_pair(pos[i], n));
        ans.push_back(make_pair(i, n));
      }
      int temp = a[i];
      swap(a[i], a[pos[i]]);
      swap(pos[i], pos[temp]);
    }
  }
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); i++) {
    printf("%d %d\n", ans[i].first, ans[i].second);
  }
  return 0;
}
