#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
ll pwr(ll a, ll b);
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<pair<int, int> > a(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> a[i].first, a[i].second = i;
  }
  vector<pair<int, int> > ans;
  for (int i = n - 1; i >= 1; --i) {
    int j = i;
    while (j < n and a[j] > a[j + 1]) {
      ans.push_back({a[j].second, a[j + 1].second});
      swap(a[j], a[j + 1]);
      ++j;
    }
  }
  reverse(ans.begin(), ans.end());
  cout << (int)ans.size() << "\n";
  for (auto it : ans) {
    cout << min(it.first, it.second) << " " << max(it.first, it.second) << "\n";
  }
}
ll pwr(ll a, ll b) {
  a %= mod;
  ll res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return res;
}
