import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Sorting {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int numb = scanner.nextInt();
        List<Integer> firstList = new ArrayList<>();
        List<Integer> secondList = new ArrayList<>();
        int sum=0;
        int[] arr = new int[numb];
        for (int i = 0; i < numb; i++) {
            arr[i] = scanner.nextInt();
        }
        int n = arr.length;
        for (int i = 0; i < n - 1; i++) {
            for (int j = 0; j < n - i - 1; j++) {
                if (arr[j] > arr[j + 1]) {
                    int temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                    firstList.add(j+1);
                    secondList.add(j+2);
                    sum+=1;
                }
            }
        }
        System.out.println(sum);
        for (int i = 0; i < firstList.size() ; i++) {
            System.out.print(firstList.get(i)+" ");
            System.out.println(secondList.get(i));
        }
    }
}

