#K84512. Minimum Possible Remaining Value

    ID: 36436 Type: Default 1000ms 256MiB

Minimum Possible Remaining Value

Minimum Possible Remaining Value

You are given an array of N positive integers. You can perform the following operation any number of times:

  • Select any two elements a and b from the array and replace them with their absolute difference |a - b|.

It can be shown that no matter how you perform the operations, the minimum possible value that can remain is the greatest common divisor (GCD) of all elements in the array, i.e., $$\gcd(a_1, a_2, \dots, a_N)$$ Compute and output this minimum possible remaining value.

inputFormat

The input is given via standard input (stdin) and has the following format:

The first line contains an integer N (1 ≤ N ≤ 105), the number of elements in the array. The second line contains N space-separated positive integers representing the elements of the array.

outputFormat

Output a single integer via standard output (stdout) which is the minimum possible value that can remain in the array after performing the operations.## sample

1
5
5