#include <bits/stdc++.h>
using namespace std;
long long read(long long x = 0) {
  int c, f = 1;
  for (c = getchar(); !isdigit(c); c = getchar())
    if (c == '-') f = -f;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;
  return f * x;
}
long long N, a[300010], pos[300010];
vector<pair<long long, long long> > ans;
void opt(long long x, long long y) {
  ans.emplace_back(make_pair(x, y));
  swap(pos[a[x]], pos[a[y]]);
  swap(a[x], a[y]);
}
int main() {
  N = read();
  long long i;
  for (i = 1; i <= N; i++) {
    a[i] = read();
    pos[a[i]] = i;
  }
  for (i = 2; i <= N / 2; i++) {
    if (pos[i] <= N / 2) {
      opt(pos[i], N);
      opt(N, i);
    } else {
      opt(pos[i], 1);
      opt(1, N);
      opt(N, i);
    }
  }
  for (; i < N; i++) {
    if (pos[i] <= N / 2) {
      opt(pos[i], N);
      opt(N, 1);
      opt(1, i);
    } else {
      opt(1, pos[i]);
      opt(1, i);
    }
  }
  if (a[1] != 1) opt(1, N);
  printf("%d\n", ans.size());
  for (auto p : ans) {
    printf("%lld %lld\n", p.first, p.second);
  }
  return 0;
}
