#K1891. Minimal Stone Value
Minimal Stone Value
Minimal Stone Value
You are given a set of stones each with an integer value. Your task is to determine the minimal possible stone value that could remain after performing the operations suggested by the problem. In fact, this is equivalent to calculating the greatest common divisor (gcd) of the given numbers. Specifically, if you have stone values \(a_1,a_2,\dots,a_n\), then the answer is \(\gcd(a_1,a_2,\dots,a_n)\). Note that if there is only one stone, its value is the answer.
Input Format: The first line contains an integer \(n\) denoting the number of stones. The second line contains \(n\) space-separated integers denoting the stone values.
Output Format: Output a single integer, the minimal stone value (i.e., the gcd of the input values).
inputFormat
The first line contains a single integer \(n\) (where \(n \geq 1\)). The second line contains \(n\) space-separated integers representing the stone values.
outputFormat
Output a single integer representing the minimal stone value, which is the greatest common divisor (gcd) of the given stone values.
## sample4
10 6 8 14
2