#K10991. GCD of Consecutive Star Distances
GCD of Consecutive Star Distances
GCD of Consecutive Star Distances
You are given the positions of N stars on a straight line in increasing order. Your task is to compute the greatest common divisor (GCD) of the distances between every two consecutive stars.
Mathematically, if the positions are given as \(a_1, a_2, \dots, a_N\), then you need to calculate the GCD of the differences \(a_2 - a_1, a_3 - a_2, \dots, a_N - a_{N-1}\).
Note: It is guaranteed that N is at least 2.
inputFormat
The first line of input contains a single integer \(N\) representing the number of stars. The second line contains \(N\) space-separated integers denoting the positions of the stars in strictly increasing order.
outputFormat
Output a single integer — the GCD of the distances between each pair of consecutive stars.
## sample4
10 15 20 30
5