#include #include using namespace std; string canConstruct(int a[]) { // Return "Yes" or "No" denoting whether you can construct the required number. string str = ""; int a_size = *(&a+1)-a; for(int i = 0; i < a_size; i++){ str = str + to_string(a[i]); } std::string::size_type sz; do{ if(int(str)%3 == 0) return "Yes"; }while(next_permutation(str.begin(), str.end())); //cout << str << endl; return "No"; } int main() { int t; cin >> t; for(int a0 = 0; a0 < t; a0++){ int n; cin >> n; int a[n]; for(int a_i = 0; a_i < n; a_i++){ cin >> a[a_i]; } string result = canConstruct(a); cout << result << endl; } return 0; }