eolymp
bolt
Try our new interface for solving problems
Problems

Kozak Vus and a chip

Kozak Vus and a chip

Recently, Kozak Vus found a chip and $n$ points that are on the same line. The chip initially has the coordinate $x$, and the $i$-th point has the coordinate $a_i$. Cossack Mustache can first choose any positive integer $k$. After that, change the chip's coordinate any number of times, adding or subtracting $k$ from it, that is, move the chip in any of the two directions by a distance of $k$. Kozak Vus is interested: at what maximum value of $k$ will the chip be able to visit all $n$ given points. \InputFile The first line contains two integers $n$ and $x$ ($2 \le n \le 10^5, -10^{18} \le x \le 10^{18}$)~--- the number of points on the line and the initial coordinate of the chip. The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($-10^{18} \le a_i \le 10^{18}$)~--- coordinates of chips. It is guaranteed that all numbers of the array $a$ are pairwise different. \OutputFile Output one number --- the maximum value of $k$ at which the chip will be able to visit all $n$ given points. \Scoring If your solution will work correctly for $n, |a_i| \le 100$, then it will score at least $30$ points.
Time limit 1 second
Memory limit 256 MiB
Input example #1
3 2
10 -2 5
Output example #1
1
Input example #2
5 5
1 7 -1 11 15
Output example #2
2
Input example #3
6 0
0 -2019 84 -6 102 87
Output example #3
3
Author Kostya Denisov