Click Here to go back to the homepage.

Another Candies Solution:


import java.util.Scanner;
import java.util.stream.LongStream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
        int cases = Integer.parseInt(sc.nextLine());
        for(int i = 0; i < cases; i++){
            sc.nextLine();
            int n = Integer.parseInt(sc.nextLine());
            sb.append(LongStream.range(0, n).reduce(0, (x, y) -> x%n + Long.parseLong(sc.nextLine())%n) % n == 0 ? "YES\n" : "NO\n");
        }
        System.out.print(sb);
    }
}