#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
int n;
vector<pair<int, int>> swaps;
int a[N];
int pos[N];
bool canISwap(int i, int j) { return (2 * abs(i - j) >= n); }
void oneswap(int i, int j) {
  swaps.push_back(make_pair(i, j));
  swap(a[i], a[j]);
  swap(pos[a[i]], pos[a[j]]);
}
void multiswap(int i, int j) {
  if (canISwap(i, j)) {
    oneswap(i, j);
  } else {
    if (canISwap(1, i) && canISwap(1, j)) {
      oneswap(1, i);
      oneswap(1, j);
      oneswap(1, i);
    } else if ((canISwap(i, n) && canISwap(j, n))) {
      oneswap(i, n);
      oneswap(j, n);
      oneswap(i, n);
    } else {
      oneswap(1, j);
      oneswap(i, n);
      oneswap(1, n);
      oneswap(1, j);
      oneswap(i, n);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    pos[a[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] != i) {
      multiswap(i, pos[i]);
    }
  }
  cout << (int)swaps.size() << "\n";
  for (pair<int, int> p : swaps) {
    cout << p.first << " " << p.second << "\n";
  }
  return 0;
}
