1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <iostream>
#include <vector>
using namespace std;

vector <int> V;
int N, sum = 0;

void Check()
{
    int minV = 0;
    for(int i = 0; i < N; i++)
    {
        if(V[i] %2 != 0)
        {
            minV = V[i];
            break;
        }
    }
    for(int i = 1; i < N; i++)
        if(minV > V[i] && V[i] % 2 != 0)
            minV = V[i];


    int maxV = 0;
    for(int i = 0; i < N; i++)
    {
        if(V[i] %2 == 0)
        {
            maxV = V[i];
            break;
        }
    }
    for(int i = 1; i < N; i++)
        if(maxV < V[i] && V[i] % 2 == 0)
            maxV = V[i];

    if(minV != 0 && sum - minV > maxV)
        cout << sum - minV << endl;
    else if(maxV != 0)
        cout << maxV << endl;
    else cout << "NIESTETY" << endl;
}

int main()
{
    std::ios_base::sync_with_stdio(false);

    int a = 0;
    cin >> N;

    for(int i = 0; i < N; i++)
    {
        cin >> a;
        sum += a;
        V.push_back(a);
    }
    if(sum % 2 == 0)
        cout << sum << endl;
    else Check();

    return 0;
}