A. Is Thor worthy?

0

0 votes
Basics of Implementation
Problem

Thor's hammer and power are stripped from him by Odin. He has to prove again that he is Worthy. N hammers are lying in front of him with numbers written on them. He has to guess whether a positive integer t(t>0) exists, which will leave the same remainder when divided by all the numbers on the hammers. Since Thor is busy, he asks your help.

 

INPUT FORMAT:

  • The first line contains one integer T denoting the number of test cases. Description of the test cases follow.

  • The first line of each test case contains a single integer N, denoting the number of hammers.

  • The second line contains N integers a1,a2,...,an, denoting the numbers written on the hammers.

OUTPUT FORMAT:

  • For each test case, print YES if there exists  t  satisfying the given conditions, or NO if it is not possible.

CONSTRAINTS:

1T1051N1051a[i]109

It is guaranteed that sum of all N over all test cases does not exceed 2105

Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation

5 mod 3 = 2
20 mod 3 = 2
17 mod 3 = 2
32 mod 3 = 2

Therefore, t=3

Editor Image

?