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

using namespace std;

void quicksort(int tab[], int left, int right){
     int i=left;
     int j=right;
     int x=tab[(left+right)>>1];
     do{
         while(tab[i]<x) i++;
         while(tab[j]>x) j--;
         if(i<=j){
             int temp=tab[i];
             tab[i]=tab[j];
             tab[j]=temp;
             i++;
             j--;
         }
     }while(i<=j);
     if(left<j) quicksort(tab,left,j);
     if(right>i) quicksort(tab,i,right);
}

int main()
{

    int n;
    cin >> n;
    int tab[n];
    int suma = 0;
    for(int i = 0; i < n; i++)
    {
       cin >> tab[i];
       suma += tab[i];
    }
    quicksort(tab, 0, n-1);

    int a = 0;

    if(suma % 2 == 0)
        cout << suma;
    else
    {
        while(a < n)
        {
            for(int i = a; i < n; i++)
            {
                if((suma - tab[i]) % 2 == 0 && (suma - tab[i]) != 0)
                {
                    cout << suma - tab[i];
                    return 0;
                }
            }
            suma -= tab[a];
            a++;
        }
        cout << "NIESTETY";
    }

return 0;
}