package No300台; import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { solver(); } static int[] A; static ArrayList s = new ArrayList<>(); static void solver() { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); A = new int[n]; for (int i = 0; i < n; i++) { A[i] = sc.nextInt(); } quicksort(0, A.length - 1); System.out.println(s.size()); for (int i = 0; i < s.size(); i++) { Swap d = s.get(i); System.out.println(d.x + " " + d.y); } int dummy = sc.nextInt(); } static void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } static int partition(int p, int r) { int x = A[r]; int i = p - 1; for (int j = p; j < r; j++) { if (A[j] <= x) { i++; int d = A[i]; A[i] = A[j]; A[j] = d; if (i != j) { s.add(new Swap(i, j)); } } } int d = A[i + 1]; A[i + 1] = A[r]; A[r] = d; if (i + 1 != r) { s.add(new Swap(i + 1, r)); } return i + 1; } static void quicksort(int p, int r) { int q = partition(p, r); if (p < q - 1) quicksort(p, q - 1); if (q + 1 < r) quicksort(q + 1, r); } static class Swap { int x; int y; Swap(int x, int y) { this.x = x; this.y = y; } } }