主要是格式问题
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int sum = 0;
int m = input.nextInt();
while (m-->0) {
int n = input.nextInt();
for (int i = 0; i < n; i++) {
int a = input.nextInt();
sum += a;
}
System.out.println(sum);
sum = 0;
if (m!=0) {
System.out.println();
}
}
}
}