#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
const int INF = INT_MAX / 2;
const long long LLINF = 9223372036854775807 / 2;
int a[MAXN * 3];
int res[MAXN * 3 * 10];
bool f = true;
void judge(int n) { f = false; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  int cnt = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int mid = n / 2;
  while (true) {
    f = true;
    for (int i = 1; i <= mid; i++) {
      if (a[i] != i) {
        res[++cnt] = i;
        res[++cnt] = n;
        swap(a[i], a[n]);
        judge(n);
        if (a[n] <= mid) {
          res[++cnt] = n;
          res[++cnt] = a[n];
          swap(a[n], a[a[n]]);
          judge(n);
        } else {
          res[++cnt] = 1;
          res[++cnt] = n;
          swap(a[1], a[n]);
          judge(n);
          res[++cnt] = 1;
          res[++cnt] = a[1];
          swap(a[1], a[a[1]]);
          judge(n);
        }
      }
    }
    for (int i = mid + 1; i <= n; i++) {
      if (a[i] != i) {
        res[++cnt] = 1;
        res[++cnt] = i;
        swap(a[1], a[i]);
        judge(n);
        if (a[1] > mid) {
          res[++cnt] = 1;
          res[++cnt] = a[1];
          swap(a[1], a[a[1]]);
          judge(n);
        } else {
          res[++cnt] = 1;
          res[++cnt] = n;
          swap(a[1], a[n]);
          judge(n);
          res[++cnt] = n;
          res[++cnt] = a[n];
          swap(a[n], a[a[n]]);
          judge(n);
        }
      }
    }
    if (a[1] != 1) {
      res[++cnt] = 1;
      res[++cnt] = n;
      swap(a[1], a[n]);
      judge(n);
    }
    if (f == true) break;
  }
  cout << cnt / 2 << endl;
  for (int i = 1; i <= cnt; i++) {
    if (i % 2 == 0)
      cout << res[i] << endl;
    else
      cout << res[i] << " ";
  }
  return 0;
}
