#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 3;
vector<pair<int, int> > ans;
const long long INF = 1e15;
int a[maxn], n, p[maxn], b[maxn];
void _swap(int x, int y) {
  ans.push_back((pair<int, int>){x, y});
  p[a[x]] = y;
  p[a[y]] = x;
  swap(a[x], a[y]);
}
void solve(int x) {
  if (p[x] == x) return;
  if (x <= n / 2 && p[x] > n / 2)
    _swap(p[x], 1), _swap(1, n), _swap(n, x);
  else if (x > n / 2 && p[x] <= n / 2)
    _swap(p[x], n), _swap(n, 1), _swap(1, x);
  else if (x <= n / 2 && p[x] <= n / 2)
    _swap(p[x], n), _swap(n, x);
  else
    _swap(p[x], 1), _swap(1, x);
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    p[a[i]] = i;
    b[i] = a[i];
  }
  for (int i = n / 2; i; i--) {
    solve(i);
    solve(n - i + 1);
  }
  cout << ans.size() << endl;
  for (auto x : ans) cout << x.first << ' ' << x.second << endl;
  for (auto x : ans) {
    swap(b[x.first], b[x.second]);
    assert(abs(x.first - x.second) >= n / 2);
  }
  for (int i = 1; i <= n; i++) assert(b[i] == i);
  return 0;
}
