#include <bits/stdc++.h>
using namespace std;
int arr[400005];
map<int, int> pos;
vector<pair<int, int> > ans;
void functioGamela(int x, int y) {
  ans.push_back({x, y});
  swap(arr[x], arr[y]);
  swap(pos[arr[x]], pos[arr[y]]);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> arr[i], pos[arr[i]] = i;
  for (int i = 2; i < n; i++) {
    if (pos[i] == i) continue;
    if (pos[i] > n / 2) {
      functioGamela(1, pos[i]);
    } else {
      functioGamela(n, pos[i]);
    }
    if (abs(pos[i] - i) >= (n / 2)) {
      functioGamela(i, pos[i]);
    } else {
      functioGamela(pos[i], n + 1 - pos[i]);
      functioGamela(i, pos[i]);
    }
  }
  if (pos[1] != 1) functioGamela(1, n);
  cout << ans.size() << endl;
  for (auto e : ans) cout << e.first << " " << e.second << endl;
  return 0;
}
