import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class kie { public static void main(String[] args) { Scanner scn = new Scanner(System.in); long first = Integer.decode(scn.nextLine()); String sec = scn.nextLine(); String[] sec_ = sec.split(" "); Long[] sec__ = getArray(sec_); long sum = 0; for(long i : sec__) { sum += i; } if(sum % 2 > 0) { sum -= getSmallestUneven(sec__); } if(sum > 0) { System.out.println(sum); } else { System.out.println("NIESTETY"); } } public static Long[] getArray(String[] arg) { List<Long> ints = new ArrayList<Long>(); for(String s : arg) { ints.add(Long.decode(s)); } return ints.toArray(new Long[0]); } public static long getSmallestUneven(Long[] arg) { long smallest = 1000; for(Long i : arg) { if(i < smallest && (i % 2 > 0)) smallest = i; } return smallest; } }
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 | import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class kie { public static void main(String[] args) { Scanner scn = new Scanner(System.in); long first = Integer.decode(scn.nextLine()); String sec = scn.nextLine(); String[] sec_ = sec.split(" "); Long[] sec__ = getArray(sec_); long sum = 0; for(long i : sec__) { sum += i; } if(sum % 2 > 0) { sum -= getSmallestUneven(sec__); } if(sum > 0) { System.out.println(sum); } else { System.out.println("NIESTETY"); } } public static Long[] getArray(String[] arg) { List<Long> ints = new ArrayList<Long>(); for(String s : arg) { ints.add(Long.decode(s)); } return ints.toArray(new Long[0]); } public static long getSmallestUneven(Long[] arg) { long smallest = 1000; for(Long i : arg) { if(i < smallest && (i % 2 > 0)) smallest = i; } return smallest; } } |