Given an array of integers, the task is to find whether it’s possible to construct an integer using all the digits of these numbers such that it would be divisible by 3. If it is possible then print “1” and if not print “0”.

**INPUT: **The first line consists of an integer **T** i.e. the number of test cases. First line of each test case consists of an integer **n. **Next line consists of n spaced integers.

**OUTPUT: **Print '1' if it is possible to form a number divisible by 3 using the array elements otherwise print '0'.

**CONSTRAINTS:**

1<=T<=100

1<=n,a[i]<=10^{5}

**EXAMPLES:
INPUT :**

2

3

40 50 90

2

1 4

**OUTPUT :**

1

0

**EXPLANATION :**

```
Input : arr[] = {40, 50, 90}
Output : Yes
We can construct a number which is
divisible by 3, for example 945000.
So the answer is Yes.
Input : arr[] = {1, 4}
Output : No
The only possible numbers are 14 and 41,
but both of them are not divisible by 3,
so the answer is No.
```

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

geetyadav | 82 |

yashrana1 | 74 |

AdityaRaj9 | 73 |

abuexshaitan | 56 |

Shashi Bhushan | 52 |

abducodes | 837 |

harshtyagi36 | 399 |

sandipbhaumik | 321 |

Akhil varma | 314 |

vamsikrishna55 | 304 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4567 |

Login to report an issue on this page.