#include <bits/stdc++.h>
using namespace std;
const int MN = 300010;
vector<pair<int, int> > ans;
int a[MN], p[MN];
void doit(int x, int y) {
  p[a[y]] = x;
  p[a[x]] = y;
  swap(a[x], a[y]);
  ans.push_back(pair<int, int>(x, y));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) p[a[i]] = i;
  for (int i = n / 2 + 1; i < n; i++) {
    if (p[i] <= n / 2) doit(p[i], n);
    doit(1, p[i]);
    doit(1, i);
  }
  for (int i = 2; i <= n / 2; i++) {
    if (p[i] != n) doit(p[i], n);
    doit(i, n);
  }
  if (a[n] != n) doit(1, n);
  cout << ((int)ans.size()) << '\n';
  for (auto curr : ans) cout << curr.first << " " << curr.second << '\n';
  return 0;
}
