#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e6 + 10;
int a[maxn], id[maxn], n;
vector<pair<int, int> > v;
void solve(int x, int y) {
  v.push_back({x, y});
  id[a[x]] = y;
  id[a[y]] = x;
  swap(a[x], a[y]);
}
void get(int x, int y) {
  if (x == y) return;
  if (x > y) swap(x, y);
  if (y - x >= n / 2)
    solve(x, y);
  else if (x > n / 2) {
    solve(1, x);
    solve(1, y);
    solve(1, x);
  } else if (y <= n / 2) {
    solve(y, n);
    solve(x, n);
    solve(y, n);
  } else {
    solve(1, y);
    solve(x, n);
    solve(1, n);
    solve(1, y);
    solve(x, n);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    id[a[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    get(i, id[i]);
  }
  printf("%d\n", v.size());
  for (int i = 0; i < (int)v.size(); i++) {
    printf("%d %d\n", v[i].first, v[i].second);
  }
  return 0;
}
