import java.util.Scanner; public class HelloWorld { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] ai = new int[n]; int[][] bij = new int[n][n]; for (int i = 0; i < n; i ++) { ai[i] = sc.nextInt(); } for (int i = 0; i < n; i ++) { for (int j = 0; j < n; j ++) { bij[i][j] = sc.nextInt(); } } sc.close(); int[] max_score_Array = new int[n]; int[][] indexs_strArray = new int[n][n]; for (int i = 0; i < n; i++) { max_score_Array[i] += ai[i]; for (int j = 0; j < n; j ++) { if (i == j) { continue; } if(ai[j] + bij[i][j] > 0) { max_score_Array[i] = max_score_Array[i] + ai[j] +bij[i][j]; indexs_strArray[i][j] = 1; } } } for (int i = 0; i < n; i++) { System.out.println(max_score_Array[i]); } } }