/*▄███████▀▀▀▀▀▀███████▄
░▐████▀▒ЗАПУСКАЕМ▒▀██████▄
░███▀▒▒▒▒▒ДЯДЮ▒▒▒▒▒▒▀█████
░▐██▒▒▒▒▒БОГДАНА▒▒▒▒▒████▌
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌
░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█
░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀
░░░░▄█████████████  █▒▒▐▌
░░░▀███▀▀████▀█████▀▒▌
░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐
░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐*/
#include<map>
#include<unordered_map>
#include<fstream>
#include<unordered_set>
#include<vector>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stdio.h>
//#include "TextFile1.h"
#include<limits>
#include<stack>
#include <iomanip>
#include<cmath>
#include<set>
#define int1 LL
#define intt int
#define ll long long
//#define int long long

#define FOR(i,n) for (int i = 0; i < n; ++i)
#define FORN(i, a, b) for (int i = a; i < b; ++i)
#define FORE(i, a, b) for (int i = a; i <= b; ++i)
#define DOWN(i,n) for (int i = n - 1; i >= 0; --i)
#define SQR(x) ((x)*(x))

#define ALL(c) (c).begin(), (c).end()
//#define map make_pair
#define pb push_back
#define fi first
#define se second
#define LL long long
//typedef pair <int, int> PII;
//typedef pair <LL, LL> PLL;
//typedef vector<int> VI;
//typedef vector<VI> VVI;
//typedef vector<LL> VL;
//typedef vector<VL> VVL;
//typedef vector<PLL> VLP;
using namespace std;
//typedef long long ll;
typedef long double LDB;
typedef float doubl;
typedef unsigned long long ULL;
const ll INF = 2e11;
const ll N = 4 * 1e5 + 1, K = 1e9 + 7;
vector<ll>tree(4 * N), mod(4 * N);
struct seg_tree {
    vector<LL> t;
    LL n = 0;
    void build(vector<LL>& a) {
        t = vector<LL>(4 * a.size());
        n = a.size();
        build(a, 1, 0, n - 1);
    }

    void build(vector<LL>& a, LL v, LL tl, LL tr) {
        if (tl == tr) {
            t[v] = a[tl];
            return;
        }
        LL mid = (tl + tr) / 2;
        build(a, 2 * v, tl, mid);
        build(a, 2 * v + 1, mid + 1, tr);
        t[v] = min(t[2 * v], t[2 * v + 1]);
    }

    LL get_gcd(LL l, LL r) {
        return get_gcd(1, 0, n - 1, l, r);
    }

    LL get_gcd(LL v, LL tl, LL tr, LL l, LL r) {
        if (tl >= l && tr <= r) {
            return t[v];
        }
        if (tl > r || tr < l) return INF;

        LL mid = (tl + tr) / 2;
        return min(get_gcd(2 * v, tl, mid, l, r), get_gcd(2 * v + 1, mid + 1, tr, l, r));
    }

    void update(LL i, LL x) {
        update(1, 0, n - 1, i, x);
    }

    void update(LL v, LL tl, LL tr, LL i, LL x) {
        if (tl == tr) {
            t[v] = x;
            return;
        }
        LL mid = (tl + tr) / 2;
        if (mid >= i) {
            update(2 * v, tl, mid, i, x);
        }
        else update(2 * v + 1, mid + 1, tr, i, x);
        t[v] = min(t[2 * v], t[2 * v + 1]);
    }
};



/*
template<typename T>
class List {
public:
    List();
    ~List();

    void pb(T n);
    void pf(T n);
    bool find(T n);

    template<typename T>
    class Node {
    public:
        T n;
        Node* next;
        Node(T nn = T(), Node* next = nullptr) {
            this->n = nn;
            this->next = next;
        }
    };
    Node<T>* head;
    Node<T>* prehead;

    Node<T>* end;
    T& operator[](const ll ind);
    ll sz;
    void del(Node<T>* t);
    void reverse(Node<T>* t, Node<T>* par);

};

template<typename T>
List<T>::List() {
    head = end = nullptr;
    sz = 0;
}
template<typename T>
void List<T>::del(Node<T>* t) {
    if (t == nullptr)return;
    del(t->next);
    delete t;
}
template<typename T>
List<T>::~List() {
    del(head);
}

template<typename T>
void List<T>::pb(T n) {
    if (head == nullptr) {
        head = new Node<T>(n);
        end = head;
    }
    else {
        auto temp = end;
        auto nnew = new Node<T>(n);
        end = nnew;
        temp->next = end;
    }
    sz++;
}
template<typename T>
void List<T>::pf(T n) {
    if (head == nullptr) {
        head = new Node<T>(n);
        end = head;
    }
    else {
        auto nnew = new Node<T>(head->n);
        nnew->next = head->next;
        head->n = n;
        head->next = nnew;
    }
    sz++;
    if (sz == 2) {
        end = head->next;
    }
}
template<typename T>
bool List<T>::find(T n) {
    auto t = head;
    while (t != nullptr) {
        if (t->n == n)return true;
        t = t->next;
    }
    return false;
}
template<typename T>
void List<T>::reverse(Node<T>* t, Node<T>* par) {
    if (t == nullptr)return;
    if (t == head) {
        prehead = t->next;
    }
    reverse(t->next, t);
    t->next = par;

    if (t == head) {
        if (sz != 2)head->next = end->next;
        else head->next = end;
        ll nn = head->n;
        head->n = end->n;
        end->n = nn;
        end->next = nullptr;
        if(sz > 2)prehead->next = end;
    }
}
template<typename T>
T& List<T>::operator[](const ll ind) {
    auto cur = head;
    ll indd = ind;
    while (indd--)cur = cur->next;
    return cur->n;
}
*/
bool check(ll n) {
    for (ll i = 2; i * i <= n; ++i) {
        if (n % i == 0)return 0;
    }
    return 1;
}
struct cmp {
    bool operator()(const string& a, const string& b)const {
        string aa = a, bb = b;
        ll rtt = 0;
        if (a.size() < b.size()) {
            while (aa.size() < bb.size()) {
                aa.push_back(bb[rtt++]);
            }
        }
        
        else {
            while (bb.size() < aa.size()) {
                bb.push_back(aa[rtt++]);
            }
        }
        ll i = 0;
        for (; i < aa.size(); ++i) {
            if (aa[i] > bb[i])return 1;
            else if (aa[i] < bb[i])return 0;
        }
        return 0;
    }
};
vector<ll>fw(1e6);
void inc(ll i, ll x) {
    for (; i < 1e6; i |= (i + 1)) {
        fw[i] = max(fw[i], x);
    }
}
ll fg(ll i) {
    ll res = 0;
    for (; i >= 0; i = (i & (i + 1)) - 1) {
        res = max(res, fw[i]);
    }
    return res;
}
ll gg(ll a, ll b) {
    if (a == 0 || b == 0)return a + b;
    if (a < b)swap(a, b);
    return gg(a % b, b);
}
ll bp(ll n, ll p) {
    if (p == 0)return 1;
    if (p % 2 == 1) {
        return (bp(n, p - 1) * n);
    }
    else {
        ll res = bp(n, p / 2);
        return (res * res);
    }

}



vector<ll>p(N), sz(N);
ll g_p(ll v) {
    if (p[v] == v)return v;
    return p[v] = g_p(p[v]);
}
void un(ll a, ll b) {
    a = g_p(a);
    b = g_p(b);
    if (sz[a] < sz[b])swap(a, b);
    sz[a] += sz[b];
    p[b] = a;
}
vector<vector<ll>>g;
vector<ll>u;
vector<ll>rr;
ll n;
bool ans = 0;
void dfs(ll v, ll cc) {
    rr.push_back(v);
    u[v]++;
    if (cc == n) {
        ans = 1;
        cout << "YES\n";
        for (auto x : rr)cout << x + 1 << " ";
        return;
    }
    for (auto to : g[v]) {
        if ((u[to] == 0) || (u[to] == 1 && to == 0)) {
            dfs(to, cc + (u[v] == 1));
        }
    }
    rr.pop_back();
    u[v]--;
}
vector<pair<ll, ll>>rt;
void ppp(vector<ll>& g, ll st, ll sss) {
    vector<ll>b = g;
    sort(b.begin(), b.end());
    for (int i = st; i < st + sss; ++i) {
        if (g[i] == b[i])continue;
        ll pk = 0;
        for (int j = i + 1; j < st + sss; ++j) {
            if (g[j] == b[i]) {
                pk = j;
                break;
            }
        }
        rt.push_back({ i + 1, pk + 1 });
        for (int ld = i; ld <= (pk + i) / 2; ld++) {
            swap(g[ld], g[pk - (ld - i)]);
        }
    }
    
}
void solve() {
    ll n;
    cin >> n;
    vector<ll>a(n), b;
    map<ll, vector<ll>>mp;
    map<ll, ll>p;
    FOR(i, n)cin >> a[i];
    b = a;
    vector<ll>lgh = a;
    vector<pair<ll, ll>>dd;
    sort(b.begin(), b.end());
    ll ress1 = 0, ress2 = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] == b[i])continue;
        ll pk = 0;
        for (int j = i + 1; j < n; ++j) {
            if (a[j] == b[i]) {
                pk = j;
                break;
            }
        }
        dd.push_back({ i + 1,pk + 1 });
        ress1 += pk - i + 1;
        for (int ld = i; ld <= (pk + i) / 2; ld++) {
            swap(a[ld], a[pk - (ld - i)]);
        }
    }
    ppp(lgh, 0, n / 2);
    ppp(lgh, 0, n);
    for (auto x : rt) {
        ress2 += x.second - x.first + 1;
    }
    if (ress2 < ress1)dd = rt;
    cout << dd.size() << "\n";
    for (auto x : dd) {
        cout << x.first << " " << x.second << "\n";
    }
}                 
 
// (ab + k (a + b) + k^2) / g = lcm;     
bool pal(ll n) {
    vector<ll>p;
    while (n) {
        p.push_back(n % 10);
        n /= 10;
    }
    for (int i = 0; i < p.size() / 2; ++i) {
        if (p[i] != p[p.size() - i - 1])return false;
    }
    return true;
}
void sw(ll a, ll b) {
    a ^= b;
    b ^= a;
    a ^= b;
}
struct Node {
    ll a, b;
    ll tt[3];
};
void merge(vector<ll>& d) {
    if (d.size() == 1)return;
    ll m = d.size() / 2;
    vector<ll>dr, dl;
    FOR(i, m)dr.push_back(d[i]);
    for (int i = m; i < d.size(); ++i)dl.push_back(d[i]);
    merge(dr);
    merge(dl);
    ll nn = dr.size(), mm = dl.size();
    ll p1 = 0, p2 = 0;
    d.clear();
    // a ^= b
    // 
    while (p1 < nn && p2 < mm) {
        if (dr[p1] < dl[p2]) {
            d.push_back(dr[p1]);
            p1++;
        }
        else {
            d.push_back(dl[p2]);
            p2++;
        }
    }
    while (p1 < nn) {
        d.push_back(dr[p1]);
        p1++;
    }
    while (p2 < mm) {
        d.push_back(dl[p2]);
        p2++;
    }
}
intt main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    ll t;
    t = 1;
    while (t--) {
        solve(); 
       
    }
}
// 5 3 6 1 2 
// 

// 3 5 6     1 2 
// 1 2 

/*
1 2 2 3 3 3
1 2 3 2 3 3
1 2 3 3 2 3
1 3 2 3 2 3
1 3 3 2 2 3
1 3 2 2 3 3
3 1 2 2 3 3
3 1 2 3 2 3
3 1 3 2 2 3
3 3 1 2 2 3
2 1 2 3 3 3
2 1 3 2 3 3
2 3 1 2 3 3
3 2 1 2 3 3

*/
/*
struct Tree {
    vector<Tree> children;
}

Tree t;
Tree* addr = &t;

Tree* current;
current = &current.children[c - 'a'];

struct Tree2 {
    map<char, Tree> childrenMap;
}
int a[5] = {1,2,3,4,5};
cout << &a == a + a.size();
                  
int* ptr = (int*)(&a + 1);
cout << *(ptr - 1);
1 2 7 8 11                        
*/