0.5 Ryn Blackwood’s Adventure: Quest Begins
Score: 10pts
Time Limit: 5.00 sec
Deep in the deserts of Agrabah, famed adventurer Ryn Blackwood uncovered a hidden cave entrance guarded by an ancient mechanism. Before her lay n glittering gems, each with a numeric value, and n-1 slots carved into the stone door.

A cryptic inscription read, "To pass, fill the slots wisely. If the total sum of all gems is odd, remove one gem to make the smallest possible sum of the remaining gems. If the sum is even, choose the largest possible sum of the gems to fill the slots." Find the sum of the gems Ryn Blackwood chose.

Constraints
1 <= n <= 100
1 <= ai <= 100

Input Format
The first line contains an integer n - the total number of gems
The second line contains n space-separated integers a1, a2, ..., an - the value of each gem.

Output Format
Print a single integer, the sum of the gems selected by Ryn

Example 1
Input:
10
7 2 4 9 3 1 8 5 6 2

Output:
38

Explanation:
As the sum of all gems is 47 which is an odd number, the output will be the smallest possible sum of 10-1=9 gems i.e., 38.

Example 2
Input:
5
4 2 3 8 5

Output:
20

Explanation:
As the sum of all gems is 22 which is an even number, the output will be the largest possible sum of 5-1=4 gems i.e., 20.

Log In to solve the Question