#include <bits/stdc++.h>
using namespace std;
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() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> arr[i];
  for (int i = 1; i <= n; i++)
    while (arr[i] != i) swapp(i, arr[i]);
  cout << ygy.size() << endl;
  for (pair<int, int> it : ygy) cout << it.first << ' ' << it.second << endl;
}
