#C8126. Alice and Bob Game

    ID: 52074 Type: Default 1000ms 256MiB

Alice and Bob Game

Alice and Bob Game

Alice and Bob play a game where Alice calculates the greatest common divisor (\(gcd\)) of a list of numbers. Given an integer \(n\) and a list of \(n\) integers, your task is to compute the \(gcd\) of the list. In mathematical terms, if the list is \(A = [a_1, a_2, \dots, a_n]\), you need to find the largest integer \(d\) such that \(d\) divides each \(a_i\).

For example, if \(n = 3\) and the list is [6, 9, 15], then the answer is 3 since \(3\) is the greatest number that divides all three numbers.

inputFormat

The first line contains an integer \(T\), the number of test cases. For each test case, the first line contains an integer \(n\) (the number of elements), followed by a line containing \(n\) space-separated integers.

outputFormat

For each test case, print a single line containing the gcd of the \(n\) integers.

## sample
2
3
6 9 15
4
2 3 5 7
3

1

</p>