#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int n, i, j, k;
  cin >> n;
  long long int val[n + 1], a[n + 1];
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    val[a[i]] = i;
  }
  vector<pair<long long int, long long int>> v;
  for (i = 1; i <= n; i++) {
    j = val[i];
    k = a[i];
    if (i == val[i]) continue;
    if ((2 * (j - i)) >= n) {
      v.push_back({i, j});
      a[i] = val[i] = i;
      a[j] = k;
      val[k] = j;
    } else if (i >= (n / 2 + 1)) {
      v.push_back({1, j});
      v.push_back({1, i});
      v.push_back({1, j});
      a[i] = val[i] = i;
      a[j] = k;
      val[k] = j;
    } else if (j <= (n / 2)) {
      v.push_back({n, j});
      v.push_back({n, i});
      v.push_back({n, j});
      a[i] = val[i] = i;
      a[j] = k;
      val[k] = j;
    } else {
      v.push_back({i, n});
      v.push_back({j, 1});
      v.push_back({1, n});
      v.push_back({1, j});
      v.push_back({i, n});
      a[i] = val[i] = i;
      a[j] = k;
      val[k] = j;
    }
  }
  cout << v.size() << endl;
  for (i = 0; i < v.size(); i++) {
    cout << v[i].first << " " << v[i].second << endl;
  }
  return 0;
}
