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
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Scanner;

public class kie {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        scanner.nextLine();
        String input = scanner.nextLine();
        String[] parts = input.split(" ");

        List<Integer> numbers = new ArrayList<>(parts.length);
        for (int i = 0; i < parts.length; ++i)
            numbers.add(Integer.parseInt(parts[i]));

        long sum = numbers.stream().mapToLong((x) -> x).sum();
        if (sum % 2 == 0)
        {
            System.out.print(sum);
            return;
        }

        Optional<Integer> firstOddItem = numbers.stream().sorted().filter(x -> x % 2 == 1).findFirst();
        if (firstOddItem.isPresent()) {
            int firstOdd = firstOddItem.get();
            long evenSum = sum - firstOdd;
            if (evenSum != 0)
            {
                System.out.print(evenSum);
                return;
            }
        }

        System.out.print("NIESTETY");
    }
}