#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5 + 7;
long long p[N];
long long pos[N];
vector<pair<long long, long long> > ans;
void f(long long first, long long second) {
  ans.push_back({first, second});
  swap(pos[p[first]], pos[p[second]]);
  swap(p[first], p[second]);
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  long long m = n >> 1;
  for (long long first = 1; first <= n; ++first) {
    cin >> p[first];
    pos[p[first]] = first;
  }
  for (long long first = 1; first <= n; ++first) {
    long long x = pos[first];
    if (x == first) {
      continue;
    } else if (x <= m) {
      f(x, n);
      f(first, n);
    } else if (first <= m && x > m) {
      f(1, x);
      f(1, n);
      f(first, n);
      if (first == 1) continue;
      f(1, n);
      f(1, x);
    } else if (first > m) {
      f(1, x);
      f(1, first);
      f(1, x);
    } else {
      exit(1);
    }
  }
  cout << ans.size() << '\n';
  for (auto e : ans) cout << e.first << ' ' << e.second << '\n';
}
