from itertools import * t = int(raw_input().strip()) for a0 in xrange(t): n = int(raw_input().strip()) a = raw_input().split() a="".join(a) perms = set([''.join(p) for p in combinations(a,len(a))]) flag=0 for i in perms: if int(i)%3==0: flag=1 break if flag==1: print "Yes" else: print "No"