#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
vector<pair<int, int>> ans;
int arr[N], idx[N], step, n;
void solve(int a, int b) {
  ans.emplace_back(a, b);
  swap(arr[a], arr[b]);
  swap(idx[arr[a]], idx[arr[b]]);
}
void solve2(int i) {
  if (idx[i] != i) {
    if (abs(idx[i] - i) >= step)
      solve(idx[i], i);
    else if (abs(n - idx[i]) >= step) {
      solve(idx[i], n);
      if (abs(idx[i] - i) < step) solve(idx[i], 1);
      solve(idx[i], i);
    } else {
      solve(idx[i], 1);
      if (abs(idx[i] - i) < step) solve(idx[i], n);
      solve(idx[i], i);
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  step = n / 2;
  for (int i = 1; i <= n; ++i) {
    cin >> arr[i];
    idx[arr[i]] = i;
  }
  for (int i = 2; i <= n - 1; ++i) solve2(i);
  solve2(1);
  cout << ans.size() << '\n';
  for (auto &it : ans) cout << it.first << ' ' << it.second << '\n';
  return 0;
}
