#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int a[n + 100], ind[n + 100];
  vector<pair<int, int> > res;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    ind[a[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    if (i != a[i]) {
      if (abs(i - ind[i]) * 2 >= n) {
        res.push_back({i, ind[i]});
      } else if (2 * i <= n && 2 * ind[i] <= n) {
        res.push_back({i, n});
        res.push_back({ind[i], n});
        res.push_back({i, n});
      } else if (2 * i > n && 2 * ind[i] > n) {
        res.push_back({1, i});
        res.push_back({1, ind[i]});
        res.push_back({1, i});
      } else {
        res.push_back({i, n});
        res.push_back({1, ind[i]});
        res.push_back({1, n});
        res.push_back({i, n});
        res.push_back({1, ind[i]});
      }
      int ind1 = ind[i];
      int ind2 = ind[a[i]];
      int x = a[i];
      swap(a[i], a[ind[i]]);
      ind[i] = ind2;
      ind[x] = ind1;
    }
  }
  printf("%lu\n", res.size());
  for (int i = 0; i < res.size(); ++i) {
    printf("%d %d\n", res[i].first, res[i].second);
  }
  return 0;
}
