import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class kie {
public static void main(String[] args) throws IOException {
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
System.out.println(run(input));
}
public static String run(BufferedReader input) throws IOException {
int n = Integer.parseInt(input.readLine());
String[] values = input.readLine().split(" ");
if (n == 1 && (Integer.parseInt(values[0]) & 1) == 1) {
return "NIESTETY";
}
int sum = 0;
int i;
int minOdd = 1001;
for (String s : values) {
i = Integer.parseInt(s);
sum += i;
if ((i & 1) == 1) {
if (i < minOdd) {
minOdd = i;
}
}
}
if ((sum & 1) == 1) {
return Integer.toString(sum - minOdd);
}
return Integer.toString(sum);
}
}
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 | import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class kie { public static void main(String[] args) throws IOException { BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); System.out.println(run(input)); } public static String run(BufferedReader input) throws IOException { int n = Integer.parseInt(input.readLine()); String[] values = input.readLine().split(" "); if (n == 1 && (Integer.parseInt(values[0]) & 1) == 1) { return "NIESTETY"; } int sum = 0; int i; int minOdd = 1001; for (String s : values) { i = Integer.parseInt(s); sum += i; if ((i & 1) == 1) { if (i < minOdd) { minOdd = i; } } } if ((sum & 1) == 1) { return Integer.toString(sum - minOdd); } return Integer.toString(sum); } } |
polski