#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0;
  bool t = false;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') t = true, ch = getchar();
  while (ch <= '9' && ch >= '0') x = x * 10 + ch - 48, ch = getchar();
  return t ? -x : x;
}
int n, p[300300], b[300300];
bool chk(int i, int j) { return 2 * abs(i - j) >= n; }
vector<pair<int, int> > Ans;
void add(int i, int j) {
  if (i == j) return;
  swap(p[i], p[j]);
  b[p[i]] = i;
  b[p[j]] = j;
  Ans.push_back(make_pair(i, j));
}
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) b[p[i] = read()] = i;
  for (int i = 1; i <= n; ++i) {
    if (i == b[i]) continue;
    if (chk(b[i], i))
      add(i, b[i]);
    else {
      int p = b[i];
      if (chk(1, p) && chk(1, i))
        add(1, p), add(1, i), add(1, p);
      else if (chk(n, i) && chk(p, n))
        add(n, i), add(p, n), add(n, i);
      else if (chk(1, p) && chk(i, n))
        add(1, p), add(i, n), add(1, n), add(1, p), add(i, n);
    }
  }
  printf("%d\n", (int)Ans.size());
  for (auto p : Ans) printf("%d %d\n", p.first, p.second);
  return 0;
}
