#include <bits/stdc++.h>
using namespace std;
namespace fio {
char bb[1000000], *s = bb, *t = bb;
streambuf* in = cin.rdbuf();
inline int read() {
  int x = 0;
  char ch =
      (s == t && (t = (s = bb) + in->sgetn(bb, 1000000), s == t) ? EOF : *s++);
  while (ch < 48)
    ch = (s == t && (t = (s = bb) + in->sgetn(bb, 1000000), s == t) ? EOF
                                                                    : *s++);
  while (ch >= 48)
    x = x * 10 + ch - 48,
    ch = (s == t && (t = (s = bb) + in->sgetn(bb, 1000000), s == t) ? EOF
                                                                    : *s++);
  return x;
}
inline void w(int x) {
  if (x >= 10) w(x / 10);
  putchar(x % 10 + 48);
}
}  // namespace fio
using fio::read;
int n, arr[300005];
vector<pair<int, int> > ygy;
bool l(int x) { return x <= n / 2; }
void add(int x) {
  if (x <= n / 2)
    ygy.push_back(pair<int, int>(x, n));
  else
    ygy.push_back(pair<int, int>(1, x));
}
void swapp(int x, int y) {
  if (x == y) return;
  swap(arr[x], arr[y]);
  if ((y - x) * 2 >= n)
    ygy.push_back(pair<int, int>(x, y));
  else if (l(x) ^ l(y))
    add(x), add(y), add(1), add(x), add(y);
  else
    add(x), add(y), add(x);
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) arr[i] = read();
  for (int i = 1; i <= n; i++)
    while (arr[i] != i) swapp(i, arr[i]);
  fio::w(ygy.size()), putchar('\n');
  for (pair<int, int> it : ygy)
    fio::w(it.first), putchar(' '), fio::w(it.second), putchar('\n');
}
