#K43922. Smallest Absolute Difference

    ID: 27417 Type: Default 1000ms 256MiB

Smallest Absolute Difference

Smallest Absolute Difference

You are given an integer n and a list of n integers representing the diameters of pipes. Your task is to compute the smallest absolute difference between any two pipe diameters.

Mathematically, if the list of diameters is \( a_1, a_2, \dots, a_n \), you need to find the minimum value of \( |a_i - a_j| \) over all pairs \( i \) and \( j \) where \( i \neq j \). It is recommended to first sort the list and then compute \( \min_{1 \leq i < n} \left( |a_{i+1} - a_i| \right) \).

The input must be read from stdin and the output should be printed to stdout.

inputFormat

The first line contains an integer n (\( n \ge 2 \)), which is the number of pipes. The second line contains n space-separated integers representing the diameters of the pipes.

outputFormat

Output a single integer which is the smallest absolute difference between any pair of pipe diameters.

## sample
5
8 1 5 3 6
1