1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i)
        cin >> a[i];
    if(n == 1 && a[0] % 2 == 1)
        cout << "NIESTETY" << endl;
    else
    {
        vector<int> odd;
        odd.reserve(n);
        copy_if(a.begin(), a.end(), back_inserter(odd), [](int x){ return x % 2;});
        int res = accumulate(a.begin(), a.end(), 0,
                [](int sum, int x){ return sum + (x % 2 == 0 ? x : 0); }) +
            accumulate(odd.begin(), odd.end(), 0) - (odd.size() % 2 == 1 ? *min_element(odd.begin(), odd.end()) : 0);
        cout << res << endl;
    }
}