Stone Game VII

Alice and Bob take turns removing stones from a row, with Alice going first.

In each turn, a player removes either the first or the last stone from the row. The player then receives points equal to the sum of the remaining stones in the row (after removal). The game ends when no stones remain.

Assuming both play optimally, return the maximum score difference (Alice's score minus Bob's score) that Alice can achieve.

Examples
Input: [5,3,1,4,2]
Output: 6
Hints

Stone Game VII

Alice and Bob take turns removing stones from a row, with Alice going first.