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
#include <iostream>
#include <vector>
#include <algorithm>
typedef unsigned int ui;
typedef unsigned long long ull;
using namespace std;

int main() {
	ui n, a;
	ull w = 0;
	vector<ui> np;
	vector<ui>::reverse_iterator rit;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a % 2 == 0)
			w += a;
		else
			np.push_back(a);
	}
	sort(np.begin(), np.end());
	if (np.size() % 2 == 0) {
		for (rit = np.rbegin(); rit != np.rend(); rit++)
			w += *rit;
		cout << w;
	}
	else if (np.size() == 1) {
		if (w == 0)
			cout << "NIESTETY";
		else
			cout << w;
	}
	else {
		for (rit = np.rbegin(); rit+1 != np.rend(); rit++) {
			w += *rit;
		}
		cout << w;
	}

	return 0;
}