using System;
using System.Collections.Generic;
using System.Linq;

class Cla {
    static int N;
    static int[] A;
    static int Cnt = 0;
    static List<int[]> Change = new List<int[]>();
    static void Main() {
        N = int.Parse(Console.ReadLine());
        A = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        for(int i = N - 1; i >= 1; i--) {
            for(int j = 0; j < i; j++) {
                if (A[j] > A[j + 1]) {
                    Cnt++;
                    int[] a = new int[2];
                    a[0] = j;
                    a[1] = j + 1;
                    Change.Add(a);
                    int w = A[j];
                    A[j] = A[j + 1];
                    A[j + 1] = w; 
                }
            }
        }
        Console.WriteLine(Cnt);
        for(int i = 0; i < Change.Count; i++) {
            Console.WriteLine(Change[i][0] + " " + Change[i][1]);

        }
        Console.Out.Flush();
        Console.ReadLine();
    }
}