#include #define loop(i,n) for( ll i=0; i::iterator i=a.begin(); i!=a.end(); i++ ) #define dloop(i,a) for( deque::iterator i=a.begin(); i!=a.end(); i++ ) #define PI 3.14159265 #define bc __builtin_popcountll #define gc getchar_unlocked #define pc putchar_unlocked #define pb push_back #define pf push_front #define rf pop_front #define rb pop_back #define mp make_pair #define fs first #define sc second #define fi ios_base::sync_with_stdio(false); cin.tie(NULL) using namespace std; typedef long long ll; typedef unsigned long long ull; const ll M = 1e9 + 7; const ll INF = 1e9; inline ll pwr(ll base,ll n,ll m){ll ans=1;while(n>0){if(n%2==1)ans=(ans*base)%m;base=(base*base)%m;n/=2;}return ans;} int main() { fi; int t; cin>>t; while(t--) { int n; cin>>n; int v = 0, a; loop(i,n) { cin>>a; v = (v+a)%3; } if(v%3==0)cout<<"Yes\n"; else cout<<"No\n"; } return 0; }