#include <bits/stdc++.h>
#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const int INF = 2000000000;
const long long LINF = 2000000000000000000;
template <typename T>
void print(vector<T>& a) {
  for (int i = 0; i < a.size(); i++) cout << a[i] << ' ';
  cout << '\n';
}
template <typename T>
void print(deque<T>& a) {
  for (int i = 0; i < a.size(); i++) cout << a[i] << ' ';
  cout << '\n';
}
template <typename T>
void print(vector<vector<T>>& a) {
  for (int i = 0; i < a.size(); i++) {
    for (int j = 0; j < a[i].size(); j++) cout << a[i][j] << ' ';
    cout << '\n';
  }
}
template <typename T>
void input(vector<T>& a) {
  for (int i = 0; i < a.size(); i++) cin >> a[i];
}
template <typename T>
void input(deque<T>& a) {
  for (int i = 0; i < a.size(); i++) cin >> a[i];
}
template <typename T>
void input(vector<vector<T>>& a) {
  for (int i = 0; i < a.size(); i++)
    for (int j = 0; j < a[i].size(); j++) cin >> a[i][j];
}
int n;
int mex(vector<int>& a) {
  vector<bool> used(n + 1, false);
  for (auto to : a) used[to] = true;
  for (int i = 0; i <= n; i++)
    if (!used[i]) return i;
}
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  input(a);
  vector<pair<int, pair<int, int>>> v;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      if (a[i] > a[j]) v.push_back({a[i], {i, -j}});
  sort((v).begin(), (v).end());
  cout << v.size() << '\n';
  for (auto to : v)
    cout << to.second.first + 1 << ' ' << -to.second.second + 1 << '\n';
}
int main() {
  int tst = 1;
  while (tst--) solve();
}
