#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define ll long long
#define ld long double
#define fi first
#define sc second
#define point pair<int,int>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define show(x) cerr << (#x) << " = " << x << '\n'
#define print(x) if (1) {cerr << (#x) << " = "; \
      for (auto it : x) cerr << it << ' '; cerr << '\n';}

using namespace std;
using namespace __gnu_pbds;

const int MAXN = 200064;
const int MAXT = 1e7 + 64;
const int ROOT = 1024;
const int MOD = 998244353;
const int LOG = 31;
const int INF = INT_MAX;
const ll MAX = LLONG_MAX;

signed main() {
      ios_base::sync_with_stdio(0);
      cin.tie(0);

      int n;
      cin >> n;
      int a[n], b[n], c[n];
      for (int i = 0; i < n; ++i)
            cin >> a[i], b[i] = c[i] = a[i];

      sort(b, b + n);
      vector<point> ans, ans2;

      for (int i = 0; i < n; ++i) {
            if (a[i] == b[i]) continue;

            for (int j = i + 1; j < n; ++j) {
                  if (b[i] == a[j]) {
                        ans.push_back({i + 1, j + 1});
                        reverse(a + i, a + j + 1);
                        break;
                  }
            }
      }

      while (!is_sorted(c, c + n)) {
            for (int i = 1; i < n; i += 1) {
                  if (c[i] < c[i - 1]) {
                        ans2.push_back({i, i + 1});
                        swap(c[i], c[i - 1]);
                  }
            }
      }

      ll sum = 0;
      for (auto it : ans)
            sum += it.second - it.first + 1;

      if (ans2.size() * 2 < sum && ans2.size() <= 2000000)
            ans = ans2;

      cout << ans.size() << '\n';
      for (auto it : ans)
            cout << it.first << ' ' << it.second << '\n';
}
