#include <bits/stdc++.h>
using namespace std;
long long int mod = 1000000007;
long long int MAX = 1e18;
void solve() {
  long long int n;
  scanf("%lld", &n);
  long long int a[n];
  vector<pair<long long int, long long int> > v(n), ans;
  for (long long int i = 0; i < n; i++) {
    long long int num;
    scanf("%lld", &num);
    a[i] = num;
    v[i] = {num - 1, i};
  }
  sort(begin(v), end(v));
  for (long long int i = n / 2, j = n / 2 - 1; i < n; i++, j--) {
    if (v[i].second > i) {
      ans.push_back({v[i].second + 1, 1});
      ans.push_back({1, i + 1});
      ans.push_back({v[i].second + 1, 1});
      v[a[i] - 1].second = v[i].second;
      swap(a[i], a[v[i].second]);
    } else if (v[i].second < i) {
      ans.push_back({v[i].second + 1, n});
      ans.push_back({n, 1});
      ans.push_back({1, i + 1});
      ans.push_back({n, 1});
      ans.push_back({v[i].second + 1, n});
      v[a[i] - 1].second = v[i].second;
      swap(a[i], a[v[i].second]);
    }
    if (v[j].second < j) {
      ans.push_back({v[j].second + 1, n});
      ans.push_back({j + 1, n});
      ans.push_back({n, v[j].second + 1});
      v[a[j] - 1].second = v[j].second;
      swap(a[j], a[v[j].second]);
    } else if (v[j].second > j) {
      ans.push_back({v[j].second + 1, 1});
      ans.push_back({1, n});
      ans.push_back({j + 1, n});
      ans.push_back({n, 1});
      ans.push_back({v[j].second + 1, 1});
      v[a[j] - 1].second = v[j].second;
      swap(a[j], a[v[j].second]);
    }
  }
  cout << ans.size() << endl;
  for (long long int i = 0; i < ans.size(); i++)
    printf("%lld %lld\n", ans[i].first, ans[i].second);
}
int main() {
  long long int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
