Alice is playing a game with his friend, Bob.
There are n piles of stones, the $i-th$ pile initially has $a_i$ stones.
Alice and Bob will take alternating turns, with Alice going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.
Assuming both players play optimally, given the starting configuration of t games, determine the winner of each game.
My attempt: say we have pile of stones as $a_1<=a_2<=a_3... <=a_n$.
If $n=1$, Alice wins as Bob can't choose anything.
If $n=2$, after Alice choose a stone from a pile the future moves of them gets predetermined.if $a_1=a_2$ ,no matter what Alice always loses, and if $a_2>a_1$ then Alice should choose a stone from $a_1$ to win.
can I get a hint on how to think further?