#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
int n, t, c, a[N], b[N], d[N];
pair<int, int> ans[N * N];
int main() {
  cin >> n;
  for (int i = 1; i < n + 1; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  for (int i = 1; i < n + 1; i++) {
    vector<pair<int, int> > v;
    for (int j = i + 1; j < n + 1; j++)
      if (a[i] > a[j]) v.push_back(make_pair(a[j], j));
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    for (int j = 0; j < v.size(); j++) ans[c++] = make_pair(i, v[j].second);
  }
  cout << c << endl;
  for (int i = 0; i < c; i++)
    cout << ans[i].first << " " << ans[i].second << endl;
}
