#include <bits/stdc++.h>
using namespace std;
int n, x;
vector<pair<int, int> > vt, ans;
bool vis[1005];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &x);
    vt.push_back(make_pair(x, i));
  }
  sort(vt.begin(), vt.end());
  for (pair<int, int> u : vt) {
    for (int i = n; i > u.second; --i)
      if (vis[i]) ans.push_back(make_pair(u.second, i));
    vis[u.second] = true;
  }
  printf("%d\n", ans.size());
  for (pair<int, int> u : ans) printf("%d %d\n", u.first, u.second);
  return 0;
}
