#include <iostream>
#include <vector>
using namespace std;
bool ends_in_3(int sum)
{
return sum % 10 == 3;
}
void solve()
{
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++)
{
cin >> a[i];
}
bool found = false;
for (int i = 0; i < n ; i++)
{
for (int j = i + 1; j < n; j++)
{
for (int k = j + 1; k < n ; k++)
{
int sum = a[i] + a[j] + a[k];
if (ends_in_3(sum))
{
found = true;
break;
}
}
}
}
if (found)
{
cout << "YES" << endl;
}
else
{
cout << "NO" << endl;
}
}
}
int main()
{
solve();
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwpib29sIGVuZHNfaW5fMyhpbnQgc3VtKSAKewogICAgcmV0dXJuIHN1bSAlIDEwID09IDM7Cn0Kdm9pZCBzb2x2ZSgpIAp7CiAgICBpbnQgdDsgCiAgICBjaW4gPj4gdDsKICAgIHdoaWxlICh0LS0pIAogICAgewogICAgICAgIGludCBuOwogICAgICAgIGNpbiA+PiBuOwogICAgICAgIHZlY3RvcjxpbnQ+IGEobik7CiAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyBpKyspCiAgICAgICAgewogICAgICAgICAgICBjaW4gPj4gYVtpXTsKICAgICAgICB9CiAgICAgICAgYm9vbCBmb3VuZCA9IGZhbHNlOyAgICAgICAgCiAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuIDsgaSsrKSAKICAgICAgICB7CiAgICAgICAgICAgIGZvciAoaW50IGogPSBpICsgMTsgaiA8IG47IGorKykgCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGZvciAoaW50IGsgPSBqICsgMTsgayA8IG4gOyBrKyspCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgaW50IHN1bSA9IGFbaV0gKyBhW2pdICsgYVtrXTsKICAgICAgICAgICAgICAgICAgICBpZiAoZW5kc19pbl8zKHN1bSkpIAogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgZm91bmQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKGZvdW5kKSAKICAgICAgICB7CiAgICAgICAgICAgIGNvdXQgPDwgIllFUyIgPDwgZW5kbDsKICAgICAgICB9IAogICAgICAgIGVsc2UgCiAgICAgICAgewogICAgICAgICAgICBjb3V0IDw8ICJOTyIgPDwgZW5kbDsKICAgICAgICB9CiAgICB9Cn0KaW50IG1haW4oKQp7CiAgICBzb2x2ZSgpOwogICAgcmV0dXJuIDA7Cn0=