#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const long long MD = 9973;
const long long MAXN = (1 << 17);
const long long MAX2 = (1 << 20);
const long long BASE = 1e9;
const long double EPS = 1e-7;
const long double PI = acos(-1);
const long long VAL = 2100;
long long n, m, k, t1, t2;
long long a[1000006], pos[1000006];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    pos[a[i]] = i;
  }
  vector<pair<long long, long long>> ans;
  for (long long i = 1; i <= n; i++) {
    if (a[i] != i) {
      if (abs(pos[i] - i) * 2 >= n) {
        ans.push_back({pos[i], pos[a[i]]});
        swap(pos[i], pos[a[i]]);
        a[pos[a[i]]] = a[i];
        a[pos[i]] = i;
      } else {
        if (i > n / 2) {
          bool da = false;
          if (!(i > n / 2 && pos[i] > n / 2) ||
              (i <= n / 2 && pos[i] <= n / 2)) {
            if (pos[i] < n / 2) {
              ans.push_back({pos[i], 1});
              swap(pos[i], pos[1]);
              da = true;
            }
          }
          ans.push_back({1, i});
          ans.push_back({1, pos[i]});
          ans.push_back({1, i});
          if (da == true) {
            ans.push_back({pos[i], pos[1]});
            swap(pos[1], pos[i]);
          }
          swap(pos[i], pos[a[i]]);
          a[pos[a[i]]] = a[i];
          a[pos[i]] = i;
        } else {
          bool da = false;
          if (!(i > n / 2 && pos[i] > n / 2) ||
              (i <= n / 2 && pos[i] <= n / 2)) {
            if (pos[i] > n / 2) {
              ans.push_back({pos[i], 1});
              swap(pos[i], pos[1]);
              da = true;
            }
          }
          ans.push_back({n, i});
          ans.push_back({n, pos[i]});
          ans.push_back({n, i});
          if (da == true) {
            ans.push_back({pos[i], pos[1]});
            swap(pos[1], pos[i]);
          }
          swap(pos[i], pos[a[i]]);
          a[pos[a[i]]] = a[i];
          a[pos[i]] = i;
        }
      }
    }
  }
  cout << ans.size() << '\n';
  for (auto i : ans) {
    cout << i.first << " " << i.second << '\n';
  }
}
