#include <bits/stdc++.h>
using namespace std;
void swp(long long int l, long long int r, vector<long long int>& a,
         vector<long long int>& pos,
         vector<pair<long long int, long long int>>& ans) {
  pos[a[l]] = r;
  pos[a[r]] = l;
  ans.push_back({l, r});
  swap(a[l], a[r]);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  cin >> n;
  vector<long long int> a(n + 1);
  vector<long long int> pos(n + 1);
  for (long long int i = 1; i <= n; i++) {
    cin >> a[i];
    pos[a[i]] = i;
  }
  vector<pair<long long int, long long int>> ans;
  for (long long int i = 2; i < n; i++) {
    long long int x = pos[i];
    if (x == i) {
      continue;
    } else if (2 * abs(x - i) >= n) {
      swp(x, i, a, pos, ans);
    } else {
      if (i <= n / 2 && x <= n / 2) {
        swp(x, n, a, pos, ans);
        swp(i, n, a, pos, ans);
      } else if (i <= n / 2 && x > n / 2) {
        swp(1, x, a, pos, ans);
        swp(1, n, a, pos, ans);
        swp(i, n, a, pos, ans);
      } else if (i > n / 2 && x <= n / 2) {
        swp(x, n, a, pos, ans);
        swp(1, n, a, pos, ans);
        swp(1, i, a, pos, ans);
      } else {
        swp(1, x, a, pos, ans);
        swp(1, i, a, pos, ans);
      }
    }
  }
  if (a[1] != 1) {
    swp(1, n, a, pos, ans);
  }
  cout << ans.size() << "\n";
  for (auto it : ans) {
    cout << it.first << " " << it.second << "\n";
  }
  return 0;
}
