#include <bits/stdc++.h>
using namespace std;
int n;
int p[300010];
int ind[300010];
vector<pair<int, int> > trans;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> p[i];
    ind[p[i]] = i;
  }
  int count = 0;
  for (int i = 1; i <= n; i++) {
    int nowInd = ind[i];
    if (nowInd == i) continue;
    if (2 * abs(nowInd - i) >= n) {
      count++;
      trans.push_back(pair<int, int>(i, nowInd));
      ind[i] = i;
      ind[p[i]] = nowInd;
      swap(p[nowInd], p[i]);
    } else {
      if (nowInd <= n / 2) {
        int c = nowInd + n / 2;
        trans.push_back(pair<int, int>(nowInd, c));
        trans.push_back(pair<int, int>(i, c));
        swap(p[nowInd], p[c]);
        swap(p[c], p[i]);
        ind[p[c]] = c;
        ind[p[i]] = i;
        ind[p[nowInd]] = nowInd;
      } else if (i <= n / 2) {
        int a = 1;
        int c = i + n / 2;
        trans.push_back(pair<int, int>(a, nowInd));
        trans.push_back(pair<int, int>(a, c));
        trans.push_back(pair<int, int>(i, c));
        trans.push_back(pair<int, int>(a, nowInd));
        swap(p[a], p[nowInd]);
        swap(p[a], p[c]);
        swap(p[i], p[c]);
        swap(p[a], p[nowInd]);
        ind[p[a]] = a;
        ind[p[c]] = c;
        ind[p[i]] = i;
        ind[p[nowInd]] = nowInd;
      } else {
        int c = i - n / 2;
        trans.push_back(pair<int, int>(nowInd, c));
        trans.push_back(pair<int, int>(i, c));
        trans.push_back(pair<int, int>(c, nowInd));
        swap(p[nowInd], p[c]);
        swap(p[c], p[i]);
        swap(p[c], p[nowInd]);
        ind[p[c]] = c;
        ind[p[i]] = i;
        ind[p[nowInd]] = nowInd;
      }
    }
  }
  cout << trans.size() << "\n";
  for (auto par : trans) {
    cout << par.first << " " << par.second << "\n";
  }
}
