Adam has N chocolates of unequal lengths.He wants that each chocolate should be of equal lengths.In order to do so,at each step,he picks two unequal length chocolates and takes their length difference 'd' and then he eats the bigger one and make it's length 'd'.He stops when all the chocolates are of equal length.Find the final length of all chocolates.
Input:
Input contains T test cases.The first line of each test case contains a single integer N, denoting the number of chocolates. The second line contains N positive integers(Ai), each separated by a single space denoting lengths of chocolates.
Output:
For each test case, output a single integer - the value of lengths of all the chocolates when they are equal (and the game terminates), in a new line.
Constraints:
1 ≤ T ≤ 100
1 ≤ N ≤ 1000
1 ≤ Ai ≤ 109
Example:
Input:
3
2
10 12
2
5 9
3
6 10 15
Output:
2
1
1
Explanation:
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.
bruceewayne | 193 |
manvirag982 | 182 |
Core_Ka_Bachha | 180 |
shivam123ahuja | 175 |
Sanjana Singh 1 | 173 |
mr_kksparrow | 433 |
manvirag982 | 398 |
TheHandle | 291 |
rajupraaa1234 | 276 |
Exception_404 | 268 |
blackshadows | 5331 |
Ibrahim Nash | 5219 |
akhayrutdinov | 5111 |
mb1973 | 4929 |
Quandray | 4567 |