import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Main { static List list; public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); int[]A = new int[N]; for(int i = 0; i < N; i++) { A[i] = scan.nextInt(); } list = new ArrayList(); bubbleSort(A, N); System.out.println(list.size() / 2); for(int i = 0; i < list.size(); i += 2) { System.out.println(list.get(i) + " " + list.get(i + 1)); } System.exit(0); int Dummy = scan.nextInt(); scan.close(); if(Dummy == -1) { System.exit(0); } } static void bubbleSort(int[]A, int n) { boolean flag = true; while(flag) { flag = false; for(int i = n - 1; i >= 1; i--) { if(A[i] < A[i - 1]) { int t = A[i]; A[i] = A[i - 1]; A[i - 1] = t; flag = true; list.add(i); list.add(i-1); } } } } }