import java.util.Scanner; public class kie { public static void main(String[] args) { Scanner SC = new Scanner(System.in); int n = SC.nextInt(); int numberOfOdds = 0; int smallestOdd = 1000; int sum = 0; for (int i = 0; i < n; i++) { int a = SC.nextInt(); sum += a; if (a % 2 == 1) { numberOfOdds++; if (a < smallestOdd) { smallestOdd = a; } } } if (numberOfOdds % 2 == 1) { sum -= smallestOdd; } System.out.println(sum != 0 ? sum : "NIESTETY"); } }
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 | import java.util.Scanner; public class kie { public static void main(String[] args) { Scanner SC = new Scanner(System.in); int n = SC.nextInt(); int numberOfOdds = 0; int smallestOdd = 1000; int sum = 0; for (int i = 0; i < n; i++) { int a = SC.nextInt(); sum += a; if (a % 2 == 1) { numberOfOdds++; if (a < smallestOdd) { smallestOdd = a; } } } if (numberOfOdds % 2 == 1) { sum -= smallestOdd; } System.out.println(sum != 0 ? sum : "NIESTETY"); } } |