AdvancedRating 1600
Coin Row Duel
Coins lie in a row. Two players alternately take a coin from either end. Both play perfectly to maximise their own total. Print the first player's total minus the second player's total.
Input
n (≤ 1000), then n values.
Output
One integer.
Sample 1
Input
4 8 15 3 7
Output
11
Sample 2
Input
2 2 2
Output
0
Output appears here