#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx,avx2")
using namespace std;
using u64 = uint64_t;
using i64 = int64_t;
using u32 = uint32_t;
using vi = vector<int>;
using vi64 = vector<i64>;
int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vi A(n);
  for (auto &x : A) {
    cin >> x;
    --x;
  }
  vi where(n);
  for (int i = (0); i < (n); ++i) {
    where[A[i]] = i;
  }
  vector<pair<int, int>> res;
  res.reserve(5 * n);
  auto swp = [&](int i, int j) {
    res.push_back({i + 1, j + 1});
    int a = A[i];
    int b = A[j];
    swap(A[i], A[j]);
    where[a] = j;
    where[b] = i;
  };
  int a = (n - 1) / 2;
  for (int ii = a; ii >= 0; --ii) {
    int x = ii;
    if (where[x] > a) {
      swp(where[x], 0);
    }
    swp(where[x], n - 1);
    swp(where[x], x);
    x = ii + 2 * (a - ii) + 1;
    if (where[x] <= a) {
      swp(where[x], n - 1);
    }
    swp(where[x], 0);
    swp(where[x], x);
  }
  cout << (res.size()) << '\n';
  for (auto &[x, y] : res) {
    cout << x << ' ' << y << '\n';
  }
  for (int i = (0); i < (n); ++i) {
    assert(where[i] == i);
  }
}
