#!/bin/python3 import sys def canConstruct(a): # Return "Yes" or "No" denoting whether you can construct the required number. s='' for i in a: s=s+i tmp=0 for i in s: tmp+=int(i) if tmp%3==0:print("Yes") else : print("No") if __name__ == "__main__": t = int(input().strip()) for a0 in range(t): n = int(input().strip()) a = list(map(str, input().strip().split(' '))) canConstruct(a)