#C6355. Largest Common Divisor
Largest Common Divisor
Largest Common Divisor
Given a list of integers, find the largest integer \(k\) (with \(k>1\)) such that every integer in the list is divisible by \(k\). If no such \(k\) exists, output -1.
The input will be provided via standard input and the result should be printed to standard output.
Hint: Use the Euclidean algorithm to compute the greatest common divisor (GCD) of the numbers. The GCD of the list will be our answer if it is greater than 1, otherwise return -1.
inputFormat
The first line contains one integer \(n\) representing the number of integers. The second line contains \(n\) space-separated integers.
outputFormat
Output a single integer which is the largest common divisor \(k\) (greater than 1) of all the numbers. If no such divisor exists, output -1.
## sample4
4 8 16 32
4