#include <bits/stdc++.h>
using namespace std;
template <class T>
void show(const vector<T> &a) {
  for (T x : a) cout << x << " ";
  cout << '\n';
}
const long long N = 1e5 + 50, oo = 1e18 + 500;
const long long mod = 998244353;
const long long M2 = 1000000093, x2 = 27162;
const long long M1 = 1000000087, x1 = 241;
const long double eps = 1e-18, PI = 2 * acos(0.0);
long long cnt = 0;
vector<vector<pair<long long, long long> > > g;
vector<long long> visit;
vector<pair<long long, long long> > solve(vector<long long> a) {
  vector<long long> b = a;
  long long n = ((long long)(a.size()));
  vector<pair<long long, long long> > ans;
  map<pair<long long, long long>, long long> mp;
  for (long long i = 0; i < n; i++) {
    vector<pair<long long, long long> > inv;
    for (long long j = i + 1; j < n; j++) {
      if (b[j] < b[i]) {
        inv.push_back({b[j], j});
      }
    }
    sort(inv.rbegin(), inv.rend());
    long long ii = i;
    for (auto pr : inv) {
      swap(a[ii], a[pr.second]);
      ans.push_back({ii, pr.second});
      mp[{ii, pr.second}] = 1;
    }
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = i + 1; j < n; j++) {
      if (b[i] > b[j] && !mp.count({i, j})) {
        ans.push_back({i, j});
      }
    }
  }
  return ans;
}
bool check(vector<long long> a, vector<pair<long long, long long> > ans) {
  long long n = ((long long)(a.size()));
  for (auto x : ans) {
    if (a[x.first] <= a[x.second]) {
      cout << x.first << " " << x.second << "is not inversion" << '\n';
      return false;
    }
  }
  long long inv = 0;
  for (long long i = 0; i < n; i++) {
    for (long long j = i + 1; j < n; j++) {
      if (a[i] > a[j]) {
        inv++;
      }
    }
  }
  if (inv != ((long long)(ans.size()))) {
    cout << "in a: " << inv << " "
         << "in ans: " << ((long long)(ans.size())) << '\n';
    return false;
  }
  vector<long long> b = a;
  for (auto x : ans) {
    swap(b[x.first], b[x.second]);
  }
  for (long long i = 1; i < n; i++) {
    if (b[i] < b[i - 1]) {
      cout << "not sorted ";
      show(b);
      return false;
    }
  }
  return true;
}
void show(vector<pair<long long, long long> > &ans) {
  cout << ((long long)(ans.size())) << '\n';
  for (auto x : ans) {
    cout << x.first + 1 << " " << x.second + 1 << '\n';
  }
}
signed main() {
  ios::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<pair<long long, long long> > ans;
  ans = solve(a);
  show(ans);
  if (!check(a, ans)) {
    return 3;
  }
}
