import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Main { static int INF = 2 << 27; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int[] A = new int[N]; for(int i = 0; i < N; i++) { A[i] = sc.nextInt(); } List u = new ArrayList<>(); List v = new ArrayList<>(); for(int i = 1; i < N; i++) { for(int j = i-1; j >= 0; j--) { if(A[j] <= A[i] || j == 0) { if(j+1 == i) break; int tmp = A[j+1]; A[j+1] = A[i]; A[i] = tmp; u.add(j+1); v.add(i); } } } System.out.println(u.size()); for(int i = 0; i < u.size(); i++) { System.out.println(u.get(i) + " " + v.get(i)); } System.out.flush(); sc.nextInt(); } static boolean isSorted(int[] A) { for(int i = 0; i < A.length-1; i++) { if(A[i] > A[i+1]) return false; } return true; } }