import java.util.Scanner;
public class kie {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
long smallestOdd = Long.MAX_VALUE;
long sum = 0;
long n = scanner.nextLong();
for (int i = 0; i < n; i++) {
long note = scanner.nextLong();
sum += note;
if (note % 2 == 1 && note < smallestOdd) {
smallestOdd = note;
}
}
scanner.close();
long max = sum % 2 == 0
? sum
: sum - smallestOdd;
if (max == 0) {
System.out.println("NIESTETY");
} else {
System.out.println(max);
}
}
}
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 | import java.util.Scanner; public class kie { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); long smallestOdd = Long.MAX_VALUE; long sum = 0; long n = scanner.nextLong(); for (int i = 0; i < n; i++) { long note = scanner.nextLong(); sum += note; if (note % 2 == 1 && note < smallestOdd) { smallestOdd = note; } } scanner.close(); long max = sum % 2 == 0 ? sum : sum - smallestOdd; if (max == 0) { System.out.println("NIESTETY"); } else { System.out.println(max); } } } |
English