t = int(input()) while t > 0: n = int(input()) arr = map(int, input().split()) tot = 0 for i in arr: tot += i if tot % 3 == 0: print("Yes") else: print("No") t -= 1