Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/saralash-eng-yaqin-juftlik

Two closest numbers

Medium 1000 ms 128 MB 45%
Share

$n$ integers $a_{1}, a_{2}, \dots, a_{n}$ are given. Choose two numbers at different positions ($i \ne j$) so that the absolute value of their difference $|a_{i} - a_{j}|$ is as small as possible. Find this smallest value.

The given numbers on the number line; the smallest distance between them is highlighted

Input

The first line contains a positive integer $n$. The second line contains $n$ integers $a_{i}$ separated by spaces.

Output

One integer — the smallest $|a_{i} - a_{j}|$.

Note

$2 \le n \le 2 * 10^{5}$
$-10^{9} \le a_{i} \le 10^{9}$

Examples

Input #1
5
15 3 9 22 11
Output #1
2
Input #2
2
-4 6
Output #2
10

Sign in to submit a solution

Signing up is free and takes a minute.