#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

#define pii pair<int, int>
#define S second
#define F first
#define pb push_back

using namespace std;

typedef long long ll;

void solve (){
  ll n;
  cin >> n;
  vector <ll> v(n), y(n);
  for (ll i = 0; i < n; i++){
    cin >> v[i];
    y[i] = v[i];
  }
  sort(y.begin(), y.end());
  vector <pii> rez;

  //for (int i = 0; i < n; i++){
  int i = 0;
  while (y != v){
    ll j = i;
    while (v[j] != y[i]){j++;}
    if (i != j) {
      rez.pb({i+1, j+1});
      reverse(v.begin()+i, v.begin()+j+1);
    }
    i++;
    //for (int h = 0; h < n; h++){cout << v[h] << " ";}
    //cout << "\n";
  }

  printf("%d\n", int(rez.size()));
  for (int i = 0; i < rez.size(); i++){
    printf("%d %d\n", rez[i].F, rez[i].S);
  }
  return;
}

int main(){
  solve();

  return 0;
}
