#include <bits/stdc++.h>
using namespace std;
void swap(vector<int> &p, vector<int> &rev_p, int i, int j) {
  int val_i = p[i];
  int val_j = p[j];
  int pos_i = rev_p[p[i]];
  int pos_j = rev_p[p[j]];
  p[i] = val_j;
  rev_p[val_j] = i;
  p[j] = val_i;
  rev_p[val_i] = j;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> p(n + 1);
  vector<int> rev_p(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> p[i];
    rev_p[p[i]] = i;
  }
  vector<pair<int, int>> soln;
  if (rev_p[1] > n / 2) {
    soln.push_back({1, rev_p[1]});
    swap(p, rev_p, 1, rev_p[1]);
  } else {
    soln.push_back({rev_p[1], n});
    swap(p, rev_p, rev_p[1], n);
    soln.push_back({rev_p[1], 1});
    swap(p, rev_p, 1, rev_p[1]);
  }
  for (int i = 2; i < n; i++) {
    if (p[i] == i) continue;
    if (i <= n / 2) {
      if (rev_p[i] - i >= n / 2) {
        soln.push_back({i, rev_p[i]});
        swap(p, rev_p, i, rev_p[i]);
      } else {
        if (rev_p[i] > n / 2) {
          soln.push_back({1, rev_p[i]});
          swap(p, rev_p, 1, rev_p[i]);
          soln.push_back({1, n});
          swap(p, rev_p, 1, n);
          soln.push_back({1, rev_p[1]});
          swap(p, rev_p, 1, rev_p[1]);
          soln.push_back({i, rev_p[i]});
          swap(p, rev_p, i, rev_p[i]);
        } else {
          soln.push_back({rev_p[i], n});
          swap(p, rev_p, n, rev_p[i]);
          soln.push_back({i, rev_p[i]});
          swap(p, rev_p, i, rev_p[i]);
        }
      }
    } else {
      soln.push_back({rev_p[i], 1});
      swap(p, rev_p, 1, rev_p[i]);
      soln.push_back({i, 1});
      swap(p, rev_p, 1, i);
      soln.push_back({rev_p[1], 1});
      swap(p, rev_p, 1, rev_p[1]);
    }
  }
  cout << soln.size() << endl;
  for (int i = 0; i < soln.size(); i++) {
    cout << soln[i].first << " " << soln[i].second << endl;
  }
  return 0;
}
