#P15032. [UOI 2021 II Stage] 棋子
[UOI 2021 II Stage] 棋子
Problem Description
Recently, Cossack Beard found a chess piece and points lying on the same straight line. The initial coordinate of the chess piece is , and the coordinate of the -th point is .
Cossack Beard can first choose any positive integer . After that, he can change the coordinate of the chess piece any number of times by adding or subtracting . That is, he moves the chess piece a distance of to either side.
Cossack Beard wants to know: what is the maximum possible such that the chess piece can visit all the given points.
Input Format
The first line contains two integers and (), which represent the number of points on the line and the initial coordinate of the chess piece, respectively.
The second line contains integers (), which are the coordinates of the points. It is guaranteed that all numbers in the array are pairwise distinct.
Output Format
Output one number, the maximum value of such that the chess piece can visit all given points.
3 2
10 -2 5
1
5 5
1 7 -1 11 15
2
6 0
0 -2019 84 -6 102 87
3
Hint
Translated by DeepSeek V3.
Translated by ChatGPT 5