import java.util.ArrayList;
import java.util.Collections;

class Main {
    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4, 5, 6};
        
        // Copy elements into a dynamic ArrayList so we can physically modify it
        ArrayList<Integer> list = new ArrayList<>();
        for (int num : arr) {
            list.add(num);
        }

        int p1 = 0;
        int p2 = 0;
        int turn = 1;

        // Loop runs until the list is completely empty
        while (!list.isEmpty()) {
            // Brute Force Rule: Always select the first element of the current array
            int selected = list.remove(0); 

            // Assign score based on whose turn it is
            if (turn % 2 != 0) {
                p1 += selected;
            } else {
                p2 += selected;
            }

            // Rule: If the latest removed element is even, reverse the remaining array
            if (selected % 2 == 0) {
                Collections.reverse(list);
            }

            turn++;
        }

        // Calculate and print the score difference
        int scoreDifference = p1 - p2;

        System.out.println("Player 1 Score: " + p1);
        System.out.println("Player 2 Score: " + p2);
        System.out.println("Score Difference (P1 - P2): " + scoreDifference);
    }
}
