#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  pair<int, int> p;
  vector<pair<int, int> > v;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  iota(b.begin(), b.end(), 0);
  sort(b.begin(), b.end(), [&](int x, int y) {
    if (a[x] != a[y]) {
      return a[x] < a[y];
    }
    return x < y;
  });
  for (int i = n - 1; i >= 0; i--) {
    int it = 0;
    for (auto j = b.begin(); j != b.end(); j++) {
      if (*j == i) {
        b.erase(j);
        break;
      }
      it++;
    }
    for (int j = it; j < b.size(); j++) {
      p.first = b[j];
      p.second = i;
      v.emplace_back(p);
    }
  }
  cout << v.size() << "\n";
  for (auto i : v) {
    cout << i.first + 1 << " " << i.second + 1 << "\n";
  }
}
int main() {
  solve();
  return 0;
}
