import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static String canConstruct(int[] a,String s) { // Return "Yes" or "No" denoting whether you can construct the required number. //char[] arr=s; int k=Integer.parseInt(s); if(k%3==0) return "Yes"; else return "No"; } public static void main(String[] args) { Scanner in = new Scanner(System.in); int z; // String s=""; int t = in.nextInt(); for(int a0 = 0; a0 < t; a0++){ int n = in.nextInt(); if(n==1){ int k=in.nextInt(); if(k%3==0) System.out.println("Yes"); else System.out.println("No"); continue; } int[] a = new int[n]; String s=""; for(int a_i = 0; a_i < n; a_i++){ z=in.nextInt(); s=z+s; a[a_i] = z; } //System.out.println(s); String result = canConstruct(a,s); System.out.println(result); } in.close(); } }