#include <bits/stdc++.h>
using namespace std;
const int N = 300030;
int n, ind1[N], ind2[N], a[N], b[N];
vector<pair<int, int> > res;
void f(int el, int i) {
  if (ind2[el] == i) return;
  if (2 * abs(ind2[el] - i) >= n) {
    int bad = ind2[el];
    res.push_back({ind2[el], i});
    swap(ind2[el], ind2[a[i]]);
    swap(a[bad], a[i]);
  } else if (2 * abs(n - ind2[el] - 1) >= n) {
    int bad = ind2[el];
    res.push_back({bad, n - 1});
    swap(ind2[el], ind2[a[n - 1]]);
    swap(a[bad], a[n - 1]);
    if (2 * abs(n - i - 1) >= n) {
      res.push_back({n - 1, i});
      swap(ind2[a[n - 1]], ind2[a[i]]);
      swap(a[n - 1], a[i]);
    } else {
      res.push_back({0, n - 1});
      swap(ind2[a[0]], ind2[a[n - 1]]);
      swap(a[0], a[n - 1]);
      res.push_back({0, i});
      swap(ind2[a[0]], ind2[a[i]]);
      swap(a[0], a[i]);
      res.push_back({0, n - 1});
      swap(ind2[a[0]], ind2[a[n - 1]]);
      swap(a[0], a[n - 1]);
    }
  } else {
    int bad = ind2[el];
    res.push_back({bad, 0});
    swap(ind2[a[bad]], ind2[a[0]]);
    swap(a[bad], a[0]);
    if (2 * i >= n) {
      res.push_back({0, i});
      swap(ind2[a[0]], ind2[a[i]]);
      swap(a[0], a[i]);
      res.push_back({0, bad});
      swap(ind2[a[0]], ind2[a[bad]]);
      swap(a[0], a[bad]);
    } else {
      res.push_back({0, n - 1});
      swap(ind2[a[0]], ind2[a[n - 1]]);
      swap(a[0], a[n - 1]);
      res.push_back({n - 1, i});
      swap(ind2[a[n - 1]], ind2[a[i]]);
      swap(a[n - 1], a[i]);
      res.push_back({0, bad});
      swap(ind2[a[0]], ind2[a[bad]]);
      swap(a[0], a[bad]);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
    ind2[a[i]] = i;
  }
  sort(b, b + n);
  for (int i = 0; i < n; i++) ind1[b[i]] = i;
  for (int i = 0; i < n; i++) f(b[i], i);
  cout << res.size() << '\n';
  for (auto& pp : res) cout << pp.first + 1 << ' ' << pp.second + 1 << '\n';
}
