#include <bits/stdc++.h>
using namespace std;
int t, n, a[200020];
unordered_map<int,int> freq;
int main() { ios::sync_with_stdio(false);cin.tie(0);
cin >> t;
while (t--) {
cin >> n;
for (int j = 0; j < 3; j++) freq[j] = 0;
for (int i = 0; i < n; i++) cin >> a[i], a[i] %= 3, freq[a[i]]++;
if (freq[1]>0 and freq[2]>0 and freq[0] <= 0) {cout << "NO\n"; continue;}
if (freq[1]+freq[2]<=0 and freq[0] > 0) {cout << "NO\n"; continue;}
if (freq[1]+freq[2]+1 < freq[0]) {cout << "NO\n"; continue;}
cout << "YES\n";
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmludCB0LCBuLCBhWzIwMDAyMF07CnVub3JkZXJlZF9tYXA8aW50LGludD4gZnJlcTsKaW50IG1haW4oKSB7IGlvczo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTtjaW4udGllKDApOwogICAgY2luID4+IHQ7CiAgICB3aGlsZSAodC0tKSB7CiAgICAgICAgY2luID4+IG47CiAgICAgICAgZm9yIChpbnQgaiA9IDA7IGogPCAzOyBqKyspIGZyZXFbal0gPSAwOwogICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKSBjaW4gPj4gYVtpXSwgYVtpXSAlPSAzLCBmcmVxW2FbaV1dKys7CiAgICAgICAgaWYgKGZyZXFbMV0+MCBhbmQgZnJlcVsyXT4wIGFuZCBmcmVxWzBdIDw9IDApIHtjb3V0IDw8ICJOT1xuIjsgY29udGludWU7fQogICAgICAgIGlmIChmcmVxWzFdK2ZyZXFbMl08PTAgYW5kIGZyZXFbMF0gPiAwKSB7Y291dCA8PCAiTk9cbiI7IGNvbnRpbnVlO30KICAgICAgICBpZiAoZnJlcVsxXStmcmVxWzJdKzEgPCBmcmVxWzBdKSB7Y291dCA8PCAiTk9cbiI7IGNvbnRpbnVlO30KICAgICAgICBjb3V0IDw8ICJZRVNcbiI7CiAgICB9CglyZXR1cm4gMDsKfQo=