#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 <int> v(n);
  for (int i = 0; i < n; i++){
    cin >> v[i];
  }
  
  vector <pii> rez;

  for (int i = 0; i < n; i++){
    ll j = 0;
    while (v[j] != i+1){j++;}
    if (i != j) {
      rez.pb({i+1, j+1});
      reverse(v.begin()+i, v.begin()+j+1);
    }
    //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;
}
