#include <bits/stdc++.h>
using namespace std;
int Set(int mask, int pos) { return mask = mask | (1 << pos); }
bool check(int mask, int pos) { return (bool)(mask & (1 << pos)); }
int pos[300005], arr[300005];
vector<pair<int, int> > v;
int n;
void move(int i) {
  v.push_back(make_pair(pos[arr[i]], pos[i]));
  int t = pos[i], x = arr[i];
  swap(arr[pos[i]], arr[i]);
  pos[i] = i;
  pos[x] = t;
}
void moveBackward(int i) {
  v.push_back(make_pair(pos[i], n));
  int t = pos[i], x = arr[n];
  swap(arr[pos[i]], arr[n]);
  pos[x] = pos[i];
  pos[i] = n;
}
void moveForward(int i) {
  v.push_back(make_pair(pos[i], 1));
  int t = pos[i], x = arr[1];
  swap(arr[pos[i]], arr[1]);
  pos[x] = pos[i];
  pos[i] = 1;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    pos[arr[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    if (arr[i] == i) continue;
    if (abs(pos[arr[i]] - pos[i]) >= n / 2) {
      move(i);
    } else {
      if (pos[i] - 1 >= (n / 2)) {
        moveForward(i);
        if ((i - pos[i]) >= n / 2)
          move(i);
        else {
          moveBackward(i);
          move(i);
        }
      } else {
        moveBackward(i);
        if (pos[i] - i >= n / 2) {
          move(i);
        } else {
          moveForward(i);
          move(i);
        }
      }
    }
  }
  cout << v.size() << endl;
  for (int i = 0; i < v.size(); i++) {
    cout << v[i].first << " " << v[i].second << endl;
  }
  return 0;
}
