#include <bits/stdc++.h>
using namespace std;
void fast_IO() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
const long long INF = 1e18;
const long long DEBUG = 1;
long long n;
vector<long long> a;
vector<pair<long long, long long>> b;
map<long long, long long> d;
vector<long long> pos;
void init() {
  cin >> n;
  a.resize(n);
  b.resize(n);
  pos.resize(n);
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
    b[i].first = a[i];
    b[i].second = i;
  }
  sort(b.begin(), b.end());
  for (long long i = 0; i < n; ++i) {
    a[b[i].second] = i;
  }
  for (long long i = 0; i < n; ++i) {
    pos[a[i]] = i;
  }
}
void print() {
  cout << "vvvvvvvvvvvvvvvvvvvvvvvv\n";
  cout << "a:\n";
  for (long long elem : a) {
    cout << elem << " ";
  }
  cout << endl;
  cout << "pos:\n";
  for (long long elem : pos) {
    cout << elem << " ";
  }
  cout << endl;
  cout << "^^^^^^^^^^^^^^^^^^^^^^^^\n";
}
void mein_swap(long long i1, long long i2) {
  swap(a[i1], a[i2]);
  pos[a[i1]] = i1;
  pos[a[i2]] = i2;
}
signed main() {
  init();
  vector<pair<long long, long long>> ans;
  for (long long x = n - 1; x >= 0; x--) {
    if (a[x] == x) {
      continue;
    }
    long long k = x - a[x];
    long long ax = a[x];
    for (long long i = 0; i < k; ++i) {
      long long i1 = pos[ax + i + 1];
      long long i2 = x;
      ans.push_back({i1, i2});
      mein_swap(i1, i2);
    }
  }
  cout << ans.size() << endl;
  for (auto pr : ans) {
    cout << pr.first + 1 << " " << pr.second + 1 << endl;
  }
  return 0;
}
