import java.util.ArrayList; import java.util.Scanner; public class Main { static int sum(ArrayList list) { int sum = 0; for (int number: list) { sum += number; } return sum; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); ArrayList numbers = new ArrayList(); while (sc.hasNextInt()) { numbers.add(sc.nextInt()); } System.out.print(sum(numbers)); if (sc.hasNext()) { System.out.print(" " + sc.next()); } } }