#include <bits/stdc++.h>
using namespace std;
int n, m, a[1000005], yer[1000005];
pair<int, int> ans[1000005];
void degis(int i, int j) {
  ans[++m] = make_pair(i, j);
  int x = a[i];
  int y = a[j];
  swap(a[i], a[j]);
  yer[x] = j;
  yer[y] = i;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
    yer[a[i]] = i;
  }
  for (int i = 1; i <= n / 2; i++) {
    int ind = n / 2 - (i - 1);
    if (a[ind] != ind) {
      if (yer[ind] <= n / 2) {
        degis(yer[ind], n);
        degis(n, ind);
      } else {
        degis(yer[ind], 1);
        degis(1, n);
        degis(n, ind);
      }
    }
    ind = n / 2 + i;
    if (a[ind] != ind) {
      if (yer[ind] > n / 2) {
        degis(1, yer[ind]);
        degis(1, ind);
      } else {
        degis(n, yer[ind]);
        degis(1, n);
        degis(1, ind);
      }
    }
  }
  printf("%d\n", m);
  for (int i = 1; i <= m; i++) printf("%d %d\n", ans[i].first, ans[i].second);
  return 0;
}
