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 = 0; i < N; i++) { for(int j = i+1; j < N-1; j++) { if(A[j] > A[j+1]) { int tmp = A[j]; A[j] = A[j+1]; A[j+1] = tmp; u.add(j); v.add(j+1); } } } 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(); } }