#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }
  vector<pair<int, int>> v;
  int i = 0, last = n - 1, first = 0;
  while (i < n) {
    int correct_pos = a[i];
    if (i == a[i]) {
      i++;
    } else if (correct_pos - i >= n / 2) {
      swap(a[i], a[correct_pos]);
      v.push_back({i, correct_pos});
    } else {
      if (last - i >= n / 2) {
        swap(a[i], a[last]);
        v.push_back({i, last});
        if (last - correct_pos >= n / 2) {
          swap(a[last], a[correct_pos]);
          v.push_back({last, correct_pos});
        } else {
          swap(a[first], a[last]);
          v.push_back({first, last});
          swap(a[first], a[correct_pos]);
          v.push_back({first, correct_pos});
          swap(a[first], a[last]);
          v.push_back({first, last});
        }
        swap(a[last], a[i]);
        v.push_back({last, i});
      } else {
        swap(a[i], a[first]);
        v.push_back({i, first});
        v.push_back({first, correct_pos});
        swap(a[first], a[correct_pos]);
        v.push_back({i, first});
        swap(a[i], a[first]);
      }
    }
  }
  cout << v.size() << endl;
  for (auto it : v) {
    cout << it.first + 1 << " " << it.second + 1 << endl;
  }
}
