#!/bin/python3 import sys def canConstruct(a): S = 0 for i in a: for j in str(i): S += int(j) if S%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(int, input().strip().split(' '))) canConstruct(a)