P2964 [USACO09NOV] A Coin Game S

Description

Farmer John's cows like to play coin games so FJ has invented with a new two-player coin game called Xoinc for them. Initially a stack of $N\ (5

Input Format

First Line: A single integer: $N$ Next $N$ Lines: Line $i+1$ contains a single integer: $C_i$

Output Format

A single integer representing the maximum value that can be made by the first player.

Explanation/Hint

Explanation: The first player starts by taking a single coin (value $1$). The opponent takes one coin as well (value $3$). The first player takes two more coins (values $1$ and $7$ -- total $9$). The second player gets the leftover coin (value $2$-- total $5$).