Curious subsequences

In this problem, we will say that a (sub)sequence of integer numbers is curious if it does not have two consecutive numbers whose sum is even. Given a sequence of nn integer numbers, what is the maximum sum of elements of all its curious subsequences?

For instance, for 8 10 101 100 120 the maximum sum is 231, corresponding to 10 101 120.

Input

Input consists of several cases, each one with nn followed by nn integer numbers between 109-10^9 and 10910^9. Assume 1n1071 \le n \le 10^7.

Output

Print the maximum possible sum for every case.

Problem information

Author: Salvador Roura

Generation: 2026-01-25T11:56:24.260Z

© Jutge.org, 2006–2026.
https://jutge.org