#K60357. Minimum Absolute Difference

    ID: 31068 Type: Default 1000ms 256MiB

Minimum Absolute Difference

Minimum Absolute Difference

You are given an integer n and a list of n integers representing toxicity levels. Your task is to compute the minimum absolute difference between any two toxicity levels after sorting the list.

Formally, given an array \(a_1, a_2, \dots, a_n\), first sort the array so that \(a_1 \leq a_2 \leq \dots \leq a_n\), then compute

[ \min_{1 \leq i < n} (a_{i+1} - a_i) ]

If there is only one element, the answer is considered to be 0.

inputFormat

The input is read from standard input (stdin) and it contains the following:

  • The first line contains an integer n representing the number of toxicity levels.
  • The second line contains n space-separated integers representing the toxicity levels.

outputFormat

Print a single integer to standard output (stdout) which is the minimum absolute difference between any two adjacent toxicity levels after sorting.

## sample
4
1 9 5 11
2

</p>