@@ -0,0 +1,1343 @@
+import java.io.BufferedReader;%0Aimport java.io.InputStreamReader;%0Aimport java.util.Arrays;%0A%0Apublic class Pancakes %7B%0A%0A    public static void main(String%5B%5D args) throws Exception %7B%0A        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));%0A        String numberOfPancakes = reader.readLine();%0A        System.out.println(new Pancakes().run(reader.readLine()));%0A    %7D%0A%0A    public String run(String input) %7B%0A        int%5B%5D pancackes = Arrays.stream(input.split(%22 %22))%0A                .mapToInt(Integer::parseInt)%0A                .toArray();%0A        int flips = 0;%0A        for (int j = pancackes.length - 1; j %3E= 1; j--) %7B%0A            int idx = 0;%0A            int maxPancake = 0;%0A            for (int i = 0; i %3C= j; i++) %7B%0A                if (pancackes%5Bi%5D %3E maxPancake) %7B%0A                    maxPancake = pancackes%5Bi%5D;%0A                    idx = i;%0A                %7D%0A            %7D%0A            if (idx %3E 0) %7B%0A                flip(pancackes, idx);%0A                flips++;%0A            %7D%0A            flip(pancackes, j);%0A            flips++;%0A        %7D%0A        return String.valueOf(flips);%0A    %7D%0A%0A    private void flip(int%5B%5D pancackes, int j) %7B%0A        for (int i = 0; i %3C (j / 2) + 1; i++) %7B%0A            int temp = pancackes%5Bi%5D;%0A            pancackes%5Bi%5D = pancackes%5Bj - i%5D;%0A            pancackes%5Bj - i%5D = temp;%0A        %7D%0A    %7D%0A%7D%0A

Add pancackes