#include <bits/stdc++.h>
using namespace std;
int A[300010];
int pos[300010];
vector<pair<int, int>> ans;
void change(int x, int y) {
  ans.push_back(make_pair(x, y));
  swap(pos[A[x]], pos[A[y]]);
  swap(A[x], A[y]);
  return;
}
int main() {
  int N;
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
    pos[A[i]] = i;
  }
  int M = N / 2;
  for (int i = M; i >= 1; i--) {
    if (pos[i] != i && pos[i] <= M) {
      change(pos[i], N);
      change(i, N);
    } else if (pos[i] > M && pos[i] - i < M) {
      change(1, pos[i]);
      change(1, N);
      change(i, N);
    } else if (pos[i] > M) {
      change(i, pos[i]);
    }
    int j = N + 1 - i;
    if (pos[j] != j && pos[j] > M) {
      change(pos[j], 1);
      change(j, 1);
    } else if (pos[j] <= M && j - pos[j] < M) {
      change(N, pos[j]);
      change(1, N);
      change(1, j);
    } else if (pos[j] <= M) {
      change(j, pos[j]);
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
}
