#include <bits/stdc++.h>
using namespace std;
int a[300010], pos[300010];
vector<pair<int, int> > v;
void swp(int x, int y) {
  v.push_back(make_pair(x, y));
  pos[a[x]] = y;
  pos[a[y]] = x;
  int tmp = a[x];
  a[x] = a[y];
  a[y] = tmp;
}
int main() {
  int n;
  while (cin >> n) {
    long long ans = 0;
    for (int i = 1; i <= n; ++i) {
      scanf("%d", a + i);
      pos[a[i]] = i;
    }
    for (int i = 1; i <= n; ++i) {
      if (pos[i] == i) {
        continue;
      }
      if (2 * abs(pos[i] - i) >= n) {
        swp(i, pos[i]);
        continue;
      }
      if (pos[i] > n / 2 && i > n / 2) {
        swp(pos[i], 1);
        swp(pos[i], i);
        swp(pos[1], 1);
      } else if (pos[i] <= n / 2 && i <= n / 2) {
        swp(pos[i], n);
        swp(pos[i], i);
      } else {
        swp(pos[i], 1);
        swp(1, n);
        swp(i, n);
        swp(1, pos[1]);
      }
    }
    cout << v.size() << endl;
    for (int i = 0; i < v.size(); ++i) {
      printf("%d %d\n", v[i].first, v[i].second);
    }
  }
  return 0;
}
