import java.util.*; public class Main { private static Scanner sc = new Scanner(System.in); public static void main(String[] args) throws Exception { int n = sc.nextInt(); int[] ary = new int[n]; for (int i = 0;i < n;i++) { ary[i] = sc.nextInt(); } List list = new ArrayList<>(); for (int i = n-1;i >= 0;i--) { for (int j = 0;j < i;j++) { int a = ary[j]; int b = ary[j+1]; if (a > b) { ary[j] = b; ary[j+1] = a; list.add(j+" "+(j+1)); } } } System.out.println(list.size()); list.stream().forEach(s -> System.out.println(s)); sc.next(); } }