#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
using namespace std;
int N, M;
int p[1500005], pos[1500005];
pair<int, int> ans[1500005];
int top = 0;
void work(int x, int y) {
  if (x > y) swap(x, y);
  if (2 * (y - x) >= N) {
    ++M;
    ans[++top] = make_pair(x, y);
  } else if (2 * (x - 1) >= N) {
    ++M;
    ans[++top] = make_pair(1, x);
    ++M;
    ans[++top] = make_pair(1, y);
    ++M;
    ans[++top] = make_pair(1, x);
  } else if (2 * (N - y) >= N) {
    ++M;
    ans[++top] = make_pair(y, N);
    ++M;
    ans[++top] = make_pair(x, N);
    ++M;
    ans[++top] = make_pair(y, N);
  } else {
    ++M;
    ans[++top] = make_pair(x, N);
    ++M;
    ans[++top] = make_pair(1, N);
    ++M;
    ans[++top] = make_pair(1, y);
    ++M;
    ans[++top] = make_pair(1, N);
    ++M;
    ans[++top] = make_pair(x, N);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> p[i];
    pos[p[i]] = i;
  }
  for (int i = 1; i <= N; i++) {
    if (pos[i] == i) continue;
    work(pos[i], i);
    int y = p[i];
    int idy = pos[i];
    p[idy] = y;
    pos[y] = idy;
    p[i] = pos[i] = i;
  }
  cout << M << endl;
  for (int i = 1; i <= M; i++) {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
  return 0;
}
