public class Solution { public static int[][] array = new int[3][3]; public static void main(String[] args) { Scanner console = new Scanner(System.in); int sumWidth = Integer.MIN_VALUE; int sumHeight = Integer.MIN_VALUE; for (int i = 0; i < array.length; i++) { for (int j = 0; j < array.length; j++) { array[i][j] = console.nextInt(); } } for (int i = 0; i < 3; i++) { int result = array[0][i] + array[1][i] + array[2][i]; if (sumWidth < result) { sumWidth = result; } } for (int i = 0; i < 3; i++) { int result2 = array[i][0] + array[i][1] + array[i][2]; if (sumHeight < result2) { sumHeight = result2; } if (sumHeight < sumWidth) { System.out.println(sumHeight); } else { System.out.println(sumWidth); } } } }