#include <bits/stdc++.h>
using namespace std;
int massiv[300002];
int pos[300002];
pair<int, int> pairs[1500001];
signed main() {
  int n;
  cin >> n;
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  for (int z = 1; z <= n; z++) {
    int a;
    cin >> a;
    massiv[z] = a;
    pos[a] = z;
  }
  int chet = 0;
  for (int x = 1; x <= n; x++) {
    if (massiv[x] != x) {
      int k = pos[x];
      if (k > n / 2 && x > n / 2) {
        pair<int, int> u;
        u.first = 1;
        u.second = k;
        pairs[chet] = (u);
        chet++;
        u.first = x;
        u.second = 1;
        pairs[chet] = (u);
        chet++;
        u.first = 1;
        u.second = k;
        pairs[chet] = (u);
        chet++;
      }
      if (k <= n / 2 && x <= n / 2) {
        pair<int, int> u;
        u.first = n;
        u.second = k;
        pairs[chet] = (u);
        chet++;
        u.first = x;
        u.second = n;
        pairs[chet] = (u);
        chet++;
        u.first = n;
        u.second = k;
        pairs[chet] = (u);
        chet++;
      }
      if (k <= n / 2 && x > n / 2) {
        if (abs(k - x) >= n / 2) {
          pair<int, int> u;
          u.first = x;
          u.second = k;
          pairs[chet] = (u);
          chet++;
        } else {
          pair<int, int> u;
          u.first = k;
          u.second = n;
          pairs[chet] = (u);
          chet++;
          u.first = x;
          u.second = 1;
          pairs[chet] = (u);
          chet++;
          u.first = n;
          u.second = 1;
          pairs[chet] = (u);
          chet++;
          u.first = k;
          u.second = n;
          pairs[chet] = (u);
          chet++;
          u.first = x;
          u.second = 1;
          pairs[chet] = (u);
          chet++;
        }
      }
      if (k > n / 2 && x <= n / 2) {
        if (abs(k - x) >= n / 2) {
          pair<int, int> u;
          u.first = x;
          u.second = k;
          pairs[chet] = (u);
          chet++;
        } else {
          pair<int, int> u;
          u.first = k;
          u.second = 1;
          pairs[chet] = (u);
          chet++;
          u.first = x;
          u.second = n;
          pairs[chet] = (u);
          chet++;
          u.first = n;
          u.second = 1;
          pairs[chet] = (u);
          chet++;
          u.first = k;
          u.second = 1;
          pairs[chet] = (u);
          chet++;
          ;
          u.first = x;
          u.second = n;
          pairs[chet] = (u);
          chet++;
        }
      }
      pos[massiv[x]] = pos[x];
      massiv[pos[x]] = massiv[x];
      massiv[x] = x;
      pos[x] = x;
    }
  }
  cout << chet << endl;
  for (int x = 0; x < chet; x++) {
    cout << pairs[x].first << " " << pairs[x].second << '\n';
  }
}
