#include #define pb push_back #define ff first #define ss second #define mp make_pair #define c1(a) cin >> a #define c2(a, b) cin >> a >> b #define scan(a) scanf("%d", &a) #define scan2(a, b) scanf("%d%d", &a, &b) #define For1(n) for(int i = 0; i < n; i++) #define For2(n) for(int j = 0; j < n; j++) using namespace std; const int MAXN = 1e5+7; typedef long long ll; typedef unsigned long long ull; typedef vector v; typedef vector vi; int main(){ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0); int T; ll arr[10000]; cin >> T; while(T--){ int x; cin >> x; for(int i = 0; i < x; i++) cin >> arr[i]; ll result = 0; for(int i = 0; i < x; i++){ result = result*10 + arr[i]; } ll sum = 0; for(int i = 0; i < x; i++){ while(result != 0){ sum = sum + result % 10; result = result / 10; } } if(sum%3 == 0) cout << "Yes\n"; else cout << "No\n"; } return 0; }