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
#include <iostream>

using namespace std;

int x;
int n[1000000];
int p[1000000];

int lp = 0, lnp = 0;

int f = 0;

int main(){
	cin >> x;

	for (int i = 0, j = 0, k = 0, q=0; i < x; i++){
		cin>>q;

		if (q % 2){
			n[j] = q;
			j++;
			lnp++;
		}
		else{
			p[k] = q;
			k++;
			lp++;
		}
	}

	for (int i = lnp; i > 1; i--){
		for (int j = 0; j < i-1; j++){
			if (n[j] < n[j + 1]){
				int k = n[j];
				n[j]= n[j + 1];
				n[j + 1] = k;
			}
		}
	}

	if (lnp % 2){
		lnp--;
	}

	for (int i = 0; i < lnp; i++){
		f += n[i];
	}

	for (int i = 0; i < lp; i++){
		f += p[i];
	}

	if (!f){
		cout << "NIESTETY";
	}
	else{
		cout << f;
	}

}