import java.io.InputStream; import java.util.Arrays; import java.util.Scanner; public class Solution { static String canConstruct(int[] a) { int finalNum = Arrays.stream(a).reduce((o1, o2) -> { return Integer.parseInt(Long.toString(Long.toString(o1).chars().asLongStream().sum() + Integer.toString(o1).chars().asLongStream().sum())); }).orElse(0); if (finalNum % 3 == 0) { return "Yes"; } else { return "No"; } } public static void main(String[] args) { Scanner scanner = null; try { scanner = new Scanner(System.in); int numQueries = scanner.nextInt(); while (scanner.hasNextLine()) { int numNumbers = scanner.nextInt(); int[] input = new int[numNumbers]; String[] o = scanner.nextLine().split(" "); if (numNumbers == 1) { o = new String[1]; o[0] = scanner.nextLine(); } else { o = scanner.nextLine().split(" "); } int index = 0; Arrays.stream(o).forEach(i -> { input[index] = Integer.parseInt(i); }); System.out.println(canConstruct(input)); } } finally { if (scanner != null) { scanner.close(); } } } }