#include <bits/stdc++.h>
using namespace std;
int n;
int metade;
int p[300001];
int r[300001];
vector<pair<int, int> > ans;
void troca(int i, int j) {
  swap(r[p[i]], r[p[j]]);
  swap(p[i], p[j]);
  if (2 * abs(i - j) >= n) {
    ans.push_back(pair<int, int>(i, j));
  } else {
    int i_ = min(i, j);
    int j_ = max(i, j);
    if (i_ <= metade && j_ > metade) {
      ans.push_back(pair<int, int>(i, n));
      ans.push_back(pair<int, int>(1, j));
      ans.push_back(pair<int, int>(1, n));
      ans.push_back(pair<int, int>(i, n));
      ans.push_back(pair<int, int>(1, j));
    } else if (i_ >= metade) {
      ans.push_back(pair<int, int>(1, i));
      ans.push_back(pair<int, int>(1, j));
      ans.push_back(pair<int, int>(1, i));
    } else {
      ans.push_back(pair<int, int>(i, n));
      ans.push_back(pair<int, int>(j, n));
      ans.push_back(pair<int, int>(i, n));
    }
  }
}
int main() {
  scanf("%d", &n);
  metade = n >> 1;
  for (int i = 1; i <= (int)(n); i++) {
    scanf("%d", &p[i]);
    r[p[i]] = i;
  }
  for (int i = 1; i <= (int)(n); i++) {
    if (i != p[i]) troca(i, r[i]);
  }
  printf("%lu\n", ans.size());
  for (pair<int, int> s : ans) {
    printf("%d %d\n", s.first, s.second);
  }
  return 0;
}
