t = int(input()) for i in range(t): n = int(input()) s = list(map(int, input().split())) a = "" z = 0 for i in range(n): a += str(s[i]) for i in a: z += int(i) if z % 3 == 0: print("Yes") else: print("No")