#include <bits/stdc++.h>
using namespace std;
int a[300001], b[300001], st[300001 * 5], ed[300001 * 5], res = 0, n;
void process(int u, int v) {
  res++;
  st[res] = min(u, v), ed[res] = max(u, v);
  swap(a[u], a[v]);
  swap(b[a[u]], b[a[v]]);
}
int main() {
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) b[a[i]] = i;
  for (int i = 1; i <= n; i++)
    if (a[i] != i) {
      if (abs(b[a[i]] - b[i]) >= n / 2)
        process(b[a[i]], b[i]);
      else if ((n - b[i] >= n / 2) && (n - i >= n / 2)) {
        process(b[i], b[a[n]]);
        process(b[a[n]], b[a[i]]);
      } else {
        process(b[i], b[a[1]]);
        if ((n - b[i] >= n / 2) && (n - i >= n / 2)) {
          process(b[i], b[a[n]]);
          process(b[a[n]], b[a[i]]);
          process(b[1], b[a[1]]);
        } else {
          process(b[i], b[a[i]]);
          process(b[a[1]], b[1]);
        }
      }
    }
  cout << res << endl;
  for (int i = 1; i <= res; i++) cout << st[i] << ' ' << ed[i] << endl;
}
