#include <bits/stdc++.h>
long long int mod = 1000000007;
using namespace std;
int n;
int a[300001];
int p[300001];
vector<pair<int, int> > ans;
void swp(int x, int y) {
  ans.push_back(make_pair(x, y));
  int d = a[x];
  int e = a[y];
  a[x] = e;
  a[y] = d;
  p[a[x]] = x;
  p[a[y]] = y;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    p[a[i]] = i;
  }
  int l = (n / 2), r = l + 1, fl = 0;
  while (r <= n) {
    if (fl == 0) {
      if (a[l] == l) {
        l--;
      } else if (p[l] > (n / 2)) {
        swp(1, p[l]);
        swp(1, n);
        swp(n, l);
        l--;
      } else {
        swp(p[l], n);
        swp(n, l);
        l--;
      }
    } else {
      if (a[r] == r) {
        r++;
      } else if (p[r] > (n / 2)) {
        swp(p[r], 1);
        swp(1, r);
        r++;
      } else {
        swp(p[r], n);
        swp(n, 1);
        swp(1, r);
        r++;
      }
    }
    fl ^= 1;
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
  return 0;
}
