You are walking along the street when a street vendor offers you a special deal. He has a row of
The vendor offers you to buy any number of consecutive emeralds from his row, as long as that selection of emeralds does not include any odd-weighted emeralds.
What is the largest total weight of emeralds you can buy with one purchase, following the rule above?
Input Specification
The input will consist of two lines. The first line contains
Output Specification
Please output one integer: the maximum possible sum of the weights of the emeralds that can be purchased as described above.
Constraints and Partial Marks
For
For the remaining
Sample Input
13
2 3 4 4 5 6 1 2 2 2 1 8 2
Sample Output
10
Explanation of Sample Output
Buying the two rightmost emeralds, with sizes
There are many suboptimal alternative purchases. These include:
- Buying the three consecutive emeralds with size
(sum = ), - Buying two of the three consecutive emeralds with size
(sum = ), - Buying the two consecutive emeralds with size
(sum = ), or - Buying a single emerald of size
, , , or .
Comments