#!/bin/ruby def canConstruct(a) s = 0 for n in a for d in n.digits s += d % 3 end end return (s % 3 == 0) ? "Yes" : "No" end t = gets.strip.to_i for a0 in (0..t-1) n = gets.strip.to_i a = gets.strip a = a.split(' ').map(&:to_i) result = canConstruct(a) puts result end