#include <bits/stdc++.h>
using namespace std;
int a[300005];
int p[300005];
int mid;
int n;
vector<pair<int, int> > out;
void performswap(int i, int j) {
  if (i > j) swap(i, j);
  int x = a[i];
  int y = a[j];
  p[x] = j;
  p[y] = i;
  swap(a[i], a[j]);
  if (i <= mid && j > mid) {
    if (i == 1) {
      out.emplace_back(1, j);
    } else if (j == n) {
      out.emplace_back(i, j);
    } else {
      out.emplace_back(1, j);
      out.emplace_back(i, n);
      out.emplace_back(1, n);
      out.emplace_back(1, j);
      out.emplace_back(i, n);
    }
  } else if (j <= mid) {
    out.emplace_back(i, n);
    out.emplace_back(j, n);
    out.emplace_back(i, n);
  } else {
    out.emplace_back(1, i);
    out.emplace_back(1, j);
    out.emplace_back(1, i);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
    p[a[i]] = i;
  }
  mid = n / 2;
  for (int i = 1; i <= n; i++) {
    int idx = p[i];
    if (idx != i) {
      performswap(idx, i);
    }
  }
  printf("%d\n", out.size());
  for (auto ans : out) {
    printf("%d %d\n", ans.first, ans.second);
  }
  return 0;
}
