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;

int N;

long long countNext(vector<int>& next) {
    for (int i = 1; i < N; i++)
        next[i] = next[i] + next[i - 1];
    for (int i = N - 1; i >= 0; i--) {
        if (next[i] % 2 == 0)
            return next[i];
    }
    return 0;
}

long long countPrev(vector<int>& prev) {
    for (int i = N - 2; i >= 0; i--)
        prev[i] = prev[i] + prev[i + 1];
    for (int i = 0; i < N; i++) {
        if (prev[i] % 2 == 0)
            return prev[i];
    }
    return 0;
}
int main(int argc, char** argv) {
    cin >> N;

    vector<int> next;
    next.resize(N);

    vector<int> prev;
    prev.resize(N);

    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        next[i] = a;
        prev[i] = a;
    }

    if (N == 1) {
        if (next[0] % 2 == 0)
            cout << next[0] << endl;
        else
            cout << "NIESTETY" << endl;
        return 0;
    }

    long long s1 = countNext(next);
    long long s2 = countPrev(prev);

    if (!s1 && !s2)
        cout << "NIESTETY" << endl;
    else {
        long long ret = s1 > s2 ? s1 : s2;
        cout << ret << endl;
    }

    return 0;
}