#include <bits/stdc++.h>

using namespace std;

string canConstruct(vector <int> a) {
    int n = a.end() - a.begin();
    int s = 0;
    for(int i=0;i<n;i++){
        int x = a[i];
        while(x){
            s += x%10;
            x /= 10;
        }
    }
    if(s%3)
        return "No";
    else return "Yes";
    // Return "Yes" or "No" denoting whether you can construct the required number.
}

int main() {
    int t;
    cin >> t;
    for(int a0 = 0; a0 < t; a0++){
        int n;
        cin >> n;
        vector<int> a(n);
        for(int a_i = 0; a_i < n; a_i++){
           cin >> a[a_i];
        }
        string result = canConstruct(a);
        cout << result << endl;
    }
    return 0;
}