#include <bits/stdc++.h>
using namespace std;
const long long MAX = 1e9;
vector<long long> p;
vector<long long> q;
vector<pair<int, int> > pairs;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  p.resize(n);
  q.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    p[i]--;
    q[p[i]] = i;
  }
  for (int i = 0; i < n; i++) {
    if (p[i] == i)
      continue;
    else {
      int j = q[i];
      int l = i, r = j;
      if (l > r) swap(l, r);
      if (2 * (r - l) >= n)
        pairs.push_back({i, j});
      else {
        if (2 * (n - 1 - r) >= n) {
          pairs.push_back({r, n - 1});
          pairs.push_back({l, n - 1});
          pairs.push_back({r, n - 1});
        } else {
          if (2 * i >= n) {
            pairs.push_back({0, l});
            pairs.push_back({0, r});
            pairs.push_back({0, l});
          } else {
            pairs.push_back({l, n - 1});
            pairs.push_back({0, r});
            pairs.push_back({0, n - 1});
            pairs.push_back({0, r});
            pairs.push_back({l, n - 1});
          }
        }
      }
      p[j] = p[i];
      p[i] = i;
      q[p[j]] = j;
      q[i] = i;
    }
  }
  cout << pairs.size() << endl;
  for (int i = 0; i < pairs.size(); i++)
    cout << pairs[i].first + 1 << " " << pairs[i].second + 1 << endl;
}
