#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vii = vector<ii>;
const ll MOD = 998244353;
const int INF = 1e9 + 9;
const int MAXN = 1000006;
int n, a[MAXN], inv[MAXN];
ii h[MAXN];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> h[i].first;
    h[i].second = i;
  }
  sort(h, h + n);
  for (int i = 0; i < n; ++i) {
    a[h[i].second] = i;
    inv[i] = h[i].second;
  }
  vii ans;
  for (int i = 0; i < n; ++i) {
    for (int j = a[i] - 1; j >= i; --j) {
      ans.emplace_back(i, inv[j]);
      inv[a[i]] = inv[j];
      swap(a[i], a[inv[j]]);
      inv[j] = i;
    }
  }
  cout << ans.size() << "\n";
  for (const auto& [i, j] : ans) {
    cout << i + 1 << " " << j + 1 << "\n";
  }
}
