#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9;
const long long MOD = 1e9 + 7;
long long power(long long a, long long b, long long m = MOD) {
  long long ans = 1;
  while (b > 0) {
    if (b & 1) ans = (ans * a) % m;
    a = (a * a) % m;
    b >>= 1;
  }
  return ans;
}
long long dir[] = {-1, 0, 1, 0, -1};
long long dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
long long dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long N = 1e5 + 1;
void solve() {
  long long i, j, n;
  cin >> n;
  vector<pair<long long, long long>> a(n);
  set<pair<long long, long long>> st;
  for (i = 0; i < n; i++) {
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(a.begin(), a.end());
  vector<pair<long long, long long>> ans;
  for (i = 0; i < n; i++) {
    if (a[i].second == i)
      continue;
    else {
      ans.push_back({a[i].second, a[a[i].second].second});
      swap(a[i].first, a[a[i].second].first);
      swap(a[i].second, a[a[i].second].second);
    }
    if (i != a[i].second) i--;
  }
  cout << ans.size() << "\n";
  for (auto p : ans) cout << p.first << " " << p.second << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  t = 1;
  while (t--) solve();
}
