Mediummatharrays
GCD of an Array
Time limit 2 s · Memory 64 MBAcceptance: —Solved by: 0
Statement
The first line contains n, the second line contains n positive integers. Print the greatest common divisor (GCD) of all elements.
Examples
Example 1
Input
3 12 18 24
Output
6
Example 2
Input
2 7 13
Output
1
Constraints
- 1 ≤ n ≤ 10^5
- 1 ≤ a_i ≤ 10^9