#include <bits/stdc++.h>
bool isFile;
using namespace std;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
void _();
void faster() {
  _();
  if (isFile) {
    freopen(
        "taskA"
        ".in",
        "r", stdin);
    freopen(
        "taskA"
        ".out",
        "w", stdout);
  }
  if (1) {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  }
}
const long long INF = 9e18;
const int inf = 2e9;
const int MOD = 998244353;
const long double PI = acos(-1);
const long double EPS = 1e-7;
const int N = (int)1e7 + 5;
const int M = 1234;
vector<pair<int, int>> g[M];
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      if (a[i] > a[j]) {
        g[j].push_back({a[i], i});
      }
    }
  }
  vector<pair<int, int>> res;
  for (int i = n - 1; i >= 0; i--) {
    sort(g[i].begin(), g[i].end());
    for (auto &&[x, y] : g[i]) {
      res.push_back({y, i});
    }
  }
  cout << res.size() << '\n';
  for (auto &&[x, y] : res) {
    cout << x + 1 << ' ' << y + 1 << '\n';
  }
}
void _() {}
int main() {
  faster();
  int t = 1;
  int id = 1;
  while (t--) {
    solve();
  }
  return 0;
}
