L - MaratonIME doesn't like odd numbers Gym - 101375L

L - MaratonIME doesn't like odd numbers

 Gym - 101375L 

Estrela is known for defending tolerance time in delay tolerance. When he was attending to his MAC101 classes, there was a 15 minutes tolerance for delays and once he got 19 minutes late to the class. Estrela lost 7 points in his grade because of this even after he tried to explain how big the line for the Hot-Dog truck was. Later that day, he was talking about this situation during a training day for MaratonIME when Yan noticed a something odd: there was a 15 minutes delay tolerance, Estrela was 19 minutes late and lost 7 points. He said: "Estrela, can't you see? These are all odd numbers!".

The observation startled them and they realized that many of MaratonIME's catchphrases had a odd number of alphanumeric characters: "Oh, Fox!", "7", "Wubalubbadubdub", among others. That could not be a coincidence! They also realized that in their own names: Estrela and Yan.

Sena, whose name doesn't fit the observations, wants people to stop worrying about this kind of nonsense and focus on their training but he's busy trying to contain the great ruckus caused by the "7 Theory".

You agree with Sena and believe that if you create a super catchphrase with even length, people won't believe this crazy theory anymore. A super catchphrase is the concatenation of some (possibly none) catchphrases, as an example, "Da Matta is big." (12 alphanumeric characters) and "What a man!" (8 alphanumeric characters) can be used to make the super catchphrase "Da Matta is big. What a man!" (22 alphanumeric characters).

Since MaratonIME has a gigantic amount of catchphrases, you have to make a program that will determine the size of the greatest even length possible for a super catchphrase that is the concatenation of some (possibly none) of MaratonIME catchphrases. Note that if no super catchphrase with even length can be created the answer is 0.

Input

On the first line there will be an integer n, the amount of catchphrases and, on the second line, n integers, the i-th integer, ai, is the amount of alphanumerics on the i-th catchphrase.

Limits

  • 1 ≤ n ≤ 105.
  • 1 ≤ ai ≤ 104.

Output

Print the largest even size of a super catchphrase.

Examples

Input

3
1 2 4

Output

6

Input

6
4 8 15 16 23 42

Output

108

#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i,j;
    priority_queue<int,vector<int>,greater<int> >q;
    scanf("%lld",&n);
    long long int sum=0;
    int a;
    while(n--)
    {
        scanf("%d",&a);
        sum+=a;
        if(a%2!=0)
            q.push(a);
    }
    if(sum%2==0)
        printf("%lld\n",sum);
    else
    {
        sum-=q.top();
        printf("%lld\n",sum);
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/rangran/article/details/81813123