#include using namespace std; long int canConstruct(long a[1000]) { // Return "Yes" or "No" denoting whether you can construct the required number. long int b[10000],i,j=0,c=0,r; for(i=0;i<=100;i++) { do { b[j]=a[i]%10; j++; a[i]=a[i]/10; }while(a[i]!=0); } for(i=0;i<=j;i++) { c=c+b[i]; } if(c%3==0) { r=1; } else { r=0; } return(r); } int main() { int t; long int r, a[1000]; cin >> t; for(int a0 = 0; a0 < t; a0++){ int n; cin >> n; for(int a_i = 0; a_i < n; a_i++){ cin >> a[a_i]; } r = canConstruct(a); if(r==1) cout <<"Yes" << endl; else cout<<"No"<