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

using namespace std;

unsigned int nr_of_bills;
unsigned long amount = 0;
unsigned short min_odd = 1001;

int main(int argc, char *argv[])
{
    cin >> nr_of_bills;

    unsigned short bills[nr_of_bills];

    for (unsigned int i=0; i < nr_of_bills; i++) {
        cin >> bills[i];
        amount +=  bills[i];

        if (min_odd > bills[i] && bills[i] % 2 != 0) {
            min_odd = bills[i];
        }
    }

    if (nr_of_bills == 1) {
        if (bills[0] % 2 == 0) {
            cout << bills[0];
        } else {
            cout << "NIESTETY";
        }
        return EXIT_SUCCESS;
    }

    if (amount % 2 == 0) {
        cout << amount;
        return EXIT_SUCCESS;
    }

    amount -= min_odd;

    cout << amount;
    return EXIT_SUCCESS;
}