P15032 [UOI 2021 II Stage] Chess Piece

Description

Recently, Cossack Beard found a chess piece and $n$ points lying on the same straight line. The initial coordinate of the chess piece is $x$, and the coordinate of the $i$-th point is $a_i$. Cossack Beard can first choose any positive integer $k$. After that, he can change the coordinate of the chess piece any number of times by adding or subtracting $k$. That is, he moves the chess piece a distance of $k$ to either side. Cossack Beard wants to know: what is the maximum possible $k$ such that the chess piece can visit all the given $n$ points.

Input Format

The first line contains two integers $n$ and $x$ ($2 \le n \le 10^5, -10^{18} \le x \le 10^{18}$), which represent the number of points on the line and the initial coordinate of the chess piece, respectively. The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($-10^{18} \le a_i \le 10^{18}$), which are the coordinates of the points. It is guaranteed that all numbers in the array $a$ are pairwise distinct.

Output Format

Output one number, the maximum value of $k$ such that the chess piece can visit all $n$ given points.

Explanation/Hint

Translated by DeepSeek V3. Translated by ChatGPT 5